本文整理汇总了Python中pymel.core.createNode函数的典型用法代码示例。如果您正苦于以下问题:Python createNode函数的具体用法?Python createNode怎么用?Python createNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _visualizer_setup
def _visualizer_setup(self):
"""Add a shader to visualize the outValue and the coneAngle."""
visualize_sdr = pm.shadingNode('surfaceShader', asShader=True,
n='visualize')
sets = pm.sets(renderable=True, noSurfaceShader=True, empty=True,
n='visualize')
visualize_sdr.outColor >> sets.surfaceShader
vis_ramp = pm.createNode('ramp', n='visualize')
vis_ramp.setAttr('type', 1)
vis_ramp.setAttr('colorEntryList[0].color', 0, 0, 0)
vis_ramp.setAttr('colorEntryList[1].position', 1)
vis_ramp.setAttr('colorEntryList[1].color', 0, 0, 0)
vis_ramp.setAttr('colorEntryList[2].position', 0)
cmds.setAttr('%s.colorEntryList[2].color' % vis_ramp, 0, 0, 0,
type='double3')
vis_ramp.setAttr('colorEntryList[3].color', 0, 0, 0)
self.ramp.outColorR >> vis_ramp.colorEntryList[1].color.colorG
rmv = pm.createNode('remapValue', n='visualize')
rmv.setAttr('inputMin', -1)
rmv.setAttr('inputMax', 0)
rmv.setAttr('outputMin', 1)
rmv.setAttr('outputMax', 0)
self.ramp.outColorR >> rmv.inputValue
rmv.outValue >> vis_ramp.colorEntryList[2].color.colorR
(self.ramp.colorEntryList[0].position >>
vis_ramp.colorEntryList[0].position)
(self.ramp.colorEntryList[3].position >>
vis_ramp.colorEntryList[3].position)
vis_ramp.outColor >> visualize_sdr.outColor
pm.defaultNavigation(source=visualize_sdr,
destination=self.sphere.getShape().instObjGroups[0],
connectToExisting=True)
示例2: createEtWorldPosRE
def createEtWorldPosRE(self):
#create etWorldPosRE
etWorldPosRE = self.createRenderElement('ExtraTexElement')
pm.rename(etWorldPosRE, 'rbEtWorldPos')
#SetAttrs on etWorldPosRE
pm.setAttr(etWorldPosRE.vray_name_extratex, 'rbEtWorldPos')
pm.setAttr(etWorldPosRE.vray_explicit_name_extratex, 'rbEtWorldPos')
pm.setAttr(etWorldPosRE.vray_affectmattes_extratex, 0)
pm.setAttr(etWorldPosRE.vray_filtering_extratex, 0)
#Create vrayfresnel tex and setAttrs
pm.select(cl = True)
vrayFresnelTex = pm.createNode('VRayFresnel')
pm.rename(vrayFresnelTex, 'rbVRayFresnelWorldPos')
pm.setAttr(vrayFresnelTex.IOR, 1)
pm.select(cl = True)
#Create sampler Info Node
samplerInfoWorldPos = pm.createNode('samplerInfo')
pm.rename(samplerInfoWorldPos, 'rbSamplerInfoWorldPos')
#connections
samplerInfoWorldPos.pointWorld >> vrayFresnelTex.frontColor
samplerInfoWorldPos.pointWorld >> vrayFresnelTex.sideColor
vrayFresnelTex.outColor >> etWorldPosRE.vray_texture_extratex
pm.select(cl = True)
#verbose
if(self.verbose): print('Extra Tex World Pos RE created')
示例3: create_copier
def create_copier(in_meshes, name='out_geo#', in_array=None, rotate=True):
# Create output mesh
out_shape = pm.createNode('mesh')
out_xform = out_shape.getParent()
out_xform.rename(name)
# Create copier node
copier = pm.createNode('copier')
copier.orient.set(1)
copier.toggleUV.set(1)
copier.outputMesh.connect(out_shape.inMesh)
# Connect input meshes
for i, mesh in enumerate(in_meshes):
shape = mesh.getShape(noIntermediate=True)
shape.worldMesh[0].connect(copier.inputMesh[i])
if not in_array:
# Connect input transforms
array = pm.createNode('transformsToArrays')
else:
array = in_array
array.outPositionPP.connect(copier.posArray)
if rotate:
array.outRotationPP.connect(copier.rotArray)
return out_xform, copier, array
示例4: closestEndOrStartVertToSurface
def closestEndOrStartVertToSurface(targetSurface, transforms):
'''
Usage:
closestEndOrStartVertToSurface(pm.PyNode('r_hand_GEO'), pm.ls(sl=True))
'''
cpom = pm.createNode('closestPointOnMesh')
distBet = pm.createNode('distanceBetween')
targetSurface.outMesh.connect(cpom.inMesh)
for transform in transforms:
closestPointAndVert = {}
loc = pm.spaceLocator(n=transform.name().replace('GEO','LOC'))
loc.translate.set( transform.getShape().vtx[-1].getPosition() )
cpom.inPosition.set(loc.translate.get())
closestVert = cpom.closestVertexIndex.get()
closestPosEnd = targetSurface.vtx[cpom.closestVertexIndex.get()].getPosition()
distBet.point1.set( closestPosEnd )
distBet.point2.set( loc.translate.get() )
distToEnd = distBet.distance.get()
closestPointAndVert[distToEnd] = [closestVert, closestPosEnd]
loc.translate.set( transform.getShape().vtx[0].getPosition() )
cpom.inPosition.set(loc.translate.get())
closestVert = cpom.closestVertexIndex.get()
closestPosStart = targetSurface.vtx[cpom.closestVertexIndex.get()].getPosition()
distBet.point1.set( closestPosStart )
distBet.point2.set( loc.translate.get() )
distToStart = distBet.distance.get()
closestPointAndVert[distToStart] = [closestVert, closestPosEnd]
loc.translate.set( closestPointAndVert[ min(distToStart, distToEnd) ][1] )
示例5: connectJacketLoc
def connectJacketLoc(twistCrv, untwistCrv, param, name='', addCrvs=[]):
'''
'''
mp = pm.createNode('motionPath', n=twistCrv+name+'_mp')
untwistCrv.worldSpace >> mp.geometryPath
mp.u.set(param)
npc = pm.createNode('nearestPointOnCurve', n=twistCrv+name+'_npc')
mp.allCoordinates >> npc.inPosition
twistCrv.worldSpace >> npc.inputCurve
allLocs = []
loc = pm.spaceLocator(n=twistCrv+name+'_loc')
npc.position >> loc.translate
allLocs.append(loc)
for crv in addCrvs:
pci = pm.createNode('pointOnCurveInfo', n=crv+name+'_pci')
npc.parameter >> pci.parameter
crv.worldSpace >> pci.inputCurve
loc = pm.spaceLocator(n=crv+name+'_loc')
pci.position >> loc.translate
allLocs.append(loc)
pm.select(allLocs)
示例6: test_export_network
def test_export_network(self, epsilon=0.00001):
pynode_a = pymel.createNode('transform')
pynode_b = pymel.createNode('transform')
old_instance = A()
old_instance.ex_int = 42
old_instance.ex_float = 3.14159
old_instance.ex_str = 'Hello World'
old_instance.ex_None = None
old_instance.ex_list_pynode = [None, pynode_a, None, pynode_b]
#
# Ensure consistency when exporting to network
#
n = libSerialization.export_network(old_instance)
network_ex_int = n.ex_int.get()
network_ex_float = n.ex_float.get()
network_ex_str = n.ex_str.get()
self.assertTrue(network_ex_int == old_instance.ex_int)
self.assertTrue(abs(network_ex_float- old_instance.ex_float) < epsilon)
self.assertTrue(network_ex_str == old_instance.ex_str)
# Note: libSerialization will NEVER export a None value since the type cannot be resolved.
self.assertTrue(not n.hasAttr('ex_None'))
#
# Ensure consistency when importing from network
#
new_instance = libSerialization.import_network(n)
self.assertTrue(network_ex_int == new_instance.ex_int)
self.assertTrue(abs(network_ex_float- new_instance.ex_float) < epsilon)
self.assertTrue(network_ex_str == new_instance.ex_str)
示例7: _attachRenderProxy
def _attachRenderProxy( self, objects ):
path = self.fileInput.text()
proxy = []
if os.path.isdir(path):
for file in glob.glob(path+"/*.mib"):
bipx = pm.createNode('mip_binaryproxy',n=file.split('/').pop().split('.')[0]+'_BINARYPROXY')
bipx.object_filename.set(file)
proxy.append(bipx)
else:
bipx = pm.createNode('mip_binaryproxy',n=path.split('/').pop().split('.')[0]+'_BINARYPROXY')
bipx.object_filename.set(path)
proxy.append( bipx )
if not objects:
for prx in proxy:
objects.append(pm.polyCube())
for arg in objects:
if len(proxy)==0: pm.error('No proxies found in folder. Womp Womp.')
elif len(proxy)>1:
print 'more than one proxy'
#turn the lo geometry shader on
arg.miExportGeoShader.set(1)
#connect the proxy to the lo's geo shader
proxy[random.randint(0,len(proxy)-1)].outValue.connect(arg.miGeoShader, f=True)
else:
print 'one proxy'
#turn the lo geometry shader on
arg.miExportGeoShader.set(1)
#connect the proxy to the lo's geo shader
proxy.pop().outValue.connect(arg.miGeoShader, f=True)
示例8: _gather_exported_alembic_info_
def _gather_exported_alembic_info_():
cmds.loadPlugin("AbcImport.mll", quiet=True)
template_obj, fields, tk = _get_shotgun_fields_from_file_name_()
if not pm.objExists("animatedAlembicGroup"):
pm.createNode("transform", name="animatedAlembicGroup")
temp, fields, tk = _get_shotgun_fields_from_file_name_()
masterAlembicTemplate = tk.templates["master_alembic_cache"]
alembicFolder = libFile.get_parent_folder(masterAlembicTemplate.apply_fields(fields))
# Get all the abc files
exported_alemblic_info = {}
if libFile.exists(alembicFolder):
for alembicFile in libFile.listfiles(alembicFolder, "abc"):
alembicFilePath = libFile.join(alembicFolder, alembicFile)
# Edited by Chet
# Project Kitten Witch 25 May 2016
# ========================================================
# Old code that was causing the list of alembics to build
# niceName = alembicFile.split(".")[0].split("_")[]
niceName = alembicFile.split(".")[0]
niceName = niceName.split("_")
niceName = " ".join(niceName[1:])
exported_alemblic_info[niceName] = alembicFilePath
return exported_alemblic_info
示例9: createSubdivApproxNode
def createSubdivApproxNode():
'''
copy of createApproxNode from mentalrayApproxEditor.mel
node will be named "mathildaSubdivApprox"
'''
# delete existing node if exists
nodeName = 'mathildaSubdivApprox'
# make sure mental ray is loaded first
if not pm.pluginInfo('Mayatomr', q=True, loaded=True):
pm.loadPlugin('Mayatomr', qt=True)
# create approx node
approxNode = pm.createNode('mentalraySubdivApprox', n=nodeName)
# get listNode
try:
mrItemsListNode = pm.ls(type='mentalrayItemsList')[0]
except IndexError:
mrItemsListNode = pm.createNode('mentalrayItemsList', n='mentalrayItemsList')
# connect approx to list
pm.connectAttr(approxNode.message, mrItemsListNode.subdivApproxs, na=True)
return approxNode
示例10: _create_custom
def _create_custom(self):
self.pos_x_remap.outputMin.set(1)
self.pos_x_remap.outputMax.set(0)
self.neg_x_remap.outputMin.set(0)
self.neg_x_remap.outputMax.set(1)
NL_mult = pm.createNode("multDoubleLinear", name="%s_NL_mult" % self.prefix)
NR_mult = pm.createNode("multDoubleLinear", name="%s_NR_mult" % self.prefix)
SL_mult = pm.createNode("multDoubleLinear", name="%s_SL_mult" % self.prefix)
SR_mult = pm.createNode("multDoubleLinear", name="%s_SR_mult" % self.prefix)
self.pos_x_remap.outValue >> NR_mult.input1
self.pos_y_remap.outValue >> NR_mult.input2
NR_mult.output >> self.control_group.nShapeR
self.neg_x_remap.outValue >> NL_mult.input1
self.pos_y_remap.outValue >> NL_mult.input2
NL_mult.output >> self.control_group.nShapeL
self.pos_x_remap.outValue >> SR_mult.input1
self.neg_y_remap.outValue >> SR_mult.input2
SR_mult.output >> self.control_group.sShapeR
self.neg_x_remap.outValue >> SL_mult.input1
self.neg_y_remap.outValue >> SL_mult.input2
SL_mult.output >> self.control_group.sShapeL
示例11: createFresnel
def createFresnel(out = None):
#创建菲涅尔节点组合
#
#参数out: 属性输出给哪个节点, 连接属性
#
#创建节点
samplerInfo = pm.createNode('samplerInfo', name = 'Fre_samplerInfo_arnold')
ramp = pm.createNode('ramp', name = 'Fre_ramp_arnold')
aiUtility, SG = pm.createSurfaceShader('aiUtility', name = 'Fresnel_arnold')
#修改属性
ramp.interpolation.set("Exponential Down")
ramp.colorEntryList[2].remove(b=1)
ramp.colorEntryList[1].position.set(1)
ramp.colorEntryList[0].color.set(1,1,1)
ramp.colorEntryList[1].color.set(0,0,0)
aiUtility.shadeMode.set(2)
#链接属性
samplerInfo.facingRatio >> ramp.uvCoord.uCoord
samplerInfo.facingRatio >> ramp.uvCoord.vCoord
ramp.outColor >> aiUtility.color
if out :
aiUtility.outColor >> out
else :
pass
return aiUtility, SG
示例12: createZ
def createZ(out = None):
#创建Z通道节点组合
#
#参数out: 属性输出给哪个节点, 连接属性
#
#创建节点
samplerInfo = pm.createNode('samplerInfo', name = 'z_samplerInfo_arnold')
multiplyDivide = pm.createNode('multiplyDivide', name = 'z_multiplyDivide_arnold')
setRange = pm.createNode('setRange', name = 'z_setRange_arnold')
aiUtility, SG = pm.createSurfaceShader('aiUtility', name = 'zdp_arnold')
#修改属性
multiplyDivide.input2X.set(-1)
setRange.minX.set(1)
setRange.oldMinX.set(0.1)
setRange.oldMaxX.set(500)
aiUtility.shadeMode.set(2)
#属性链接
samplerInfo.pointCameraZ >> multiplyDivide.input1X
multiplyDivide.outputX >> setRange.valueX
setRange.message >> aiUtility.colorR
setRange.message >> aiUtility.colorG
setRange.message >> aiUtility.colorB
if out :
aiUtility.outColor >> out
else :
pass
return aiUtility, SG
示例13: wiggleJointChain
def wiggleJointChain(strPnt, endPnt, side='FL', chainPos='Upper'):
'''
create joint chain between two points (strPnt & endPnt). require name string of strPnt & endPnt
'''
strPos = pm.xform( strPnt, q=True, ws=True, translation=True )
endPos = pm.xform( endPnt, q=True, ws=True, translation=True )
if side.endswith('L'):
sideLabel = 1
elif side.endswith('R'):
sideLabel = 2
ikSpCrv = pm.curve( degree=2, editPoint=( strPos, endPos) )
ikSpCrv.rename( 'wiggle_%s_%s_CRV'%(side, chainPos) )
ikSpCrvShp = ikSpCrv.listRelatives(shapes=True)[0]
pm.select(clear=True)
jnt2pos = pm.pointOnCurve( ikSpCrv, pr=0.3333, turnOnPercentage=True)
jnt3pos = pm.pointOnCurve( ikSpCrv, pr=0.6667, turnOnPercentage=True )
jntPos = ( strPos, jnt2pos, jnt3pos, endPos )
jntList = []
for pnt in jntPos:
jName = 'Wiggle_%s_%s_%02d'%(side, chainPos, jntPos.index(pnt)+1)
newJoint = pm.joint(name=jName, p=pnt)
newJoint.side.set(sideLabel)
newJoint.__getattr__('type').set(18)
newJoint.otherType.set(jName)
jntList.append(newJoint)
pm.joint( jntList[0], edit=True, orientJoint='xyz', secondaryAxisOrient='xup', children=True, zeroScaleOrient=True )
ikHandle = pm.ikHandle( name='Wiggle_%s_%s_ikHandle'%(side, chainPos),
solver='ikSplineSolver',
createCurve=False,
curve=ikSpCrvShp,
startJoint=jntList[0].name(),
endEffector=jntList[-1].name(),
rootOnCurve=False,
createRootAxis=True,
parentCurve=False )
jntGrp = jntList[0].listRelatives(parent=True)[0]
jntGrp.rename('Wiggle_%s_%s'%(side, chainPos))
crvInfo = pm.createNode('curveInfo', name='crvInf_wiggle_%s_%s'%(side, chainPos))
multDiv1 = pm.createNode('multiplyDivide', name='md_wiggle_%s_%s_01'%(side, chainPos))
multDiv2 = pm.createNode('multiplyDivide', name='md_wiggle_%s_%s_02'%(side, chainPos))
ikSpCrvShp.worldSpace >> crvInfo.inputCurve
arcLgt = crvInfo.arcLength.get()
multDiv1.input2X.set(arcLgt)
multDiv1.operation.set(2)
spacing = jntList[1].tx.get()
multDiv2.input2X.set(spacing)
multDiv1.outputX >> multDiv2.input1X
crvInfo.arcLength >> multDiv1.input1X
for jnt in jntList[1:]:
multDiv2.outputX >> jnt.tx
return ikSpCrvShp, ikSpCrv, ikHandle[0], jntGrp
示例14: build
def build(self, no_subdiv=False, num_ctrl=None, degree=3, create_ctrl=True, constraint=False, rot_fol=True, *args,
**kwargs):
super(Ribbon, self).build(create_grp_anm=create_ctrl, *args, **kwargs)
if num_ctrl is not None:
self.num_ctrl = num_ctrl
nomenclature_rig = self.get_nomenclature_rig()
# Create the plane and align it with the selected bones
plane_tran = next(
(input for input in self.input if libPymel.isinstance_of_shape(input, pymel.nodetypes.NurbsSurface)), None)
if plane_tran is None:
plane_name = nomenclature_rig.resolve("ribbonPlane")
if no_subdiv: # We don't want any subdivision in the plane, so use only 2 bones to create it
no_subdiv_degree = 2
if degree < 2:
no_subdiv_degree = degree
plane_tran = libRigging.create_nurbs_plane_from_joints([self.chain_jnt[0], self.chain_jnt[-1]],
degree=no_subdiv_degree, width=self.width)
else:
plane_tran = libRigging.create_nurbs_plane_from_joints(self.chain_jnt, degree=degree, width=self.width)
plane_tran.rename(plane_name)
plane_tran.setParent(self.grp_rig)
self._ribbon_shape = plane_tran.getShape()
# Create the follicule needed for the system on the skinned bones
self.attach_to_plane(rot_fol)
# TODO : Support aim constraint for bones instead of follicle rotation?
follicles_grp = pymel.createNode("transform")
follicle_grp_name = nomenclature_rig.resolve("follicleGrp")
follicles_grp.rename(follicle_grp_name)
follicles_grp.setParent(self.grp_rig)
for n in self._follicles:
n.setParent(follicles_grp)
# Create the joints that will drive the ribbon.
# TODO: Support other shapes than straight lines...
self._ribbon_jnts = libRigging.create_chain_between_objects(
self.chain_jnt.start, self.chain_jnt.end, self.num_ctrl, parented=False)
# Group all the joints
ribbon_chain_grp_name = nomenclature_rig.resolve('ribbonChainGrp')
self.ribbon_chain_grp = pymel.createNode('transform', name=ribbon_chain_grp_name, parent=self.grp_rig)
align_chain = True if len(self.chain_jnt) == len(self._ribbon_jnts) else False
for i, jnt in enumerate(self._ribbon_jnts):
# Align the ribbon joints with the real joint to have a better rotation ctrl
ribbon_jnt_name = nomenclature_rig.resolve('ribbonJnt{0:02d}'.format(i))
jnt.rename(ribbon_jnt_name)
jnt.setParent(self.ribbon_chain_grp)
if align_chain:
matrix = self.chain_jnt[i].getMatrix(worldSpace=True)
jnt.setMatrix(matrix, worldSpace=True)
# TODO - Improve skinning smoothing by setting manually the skin...
pymel.skinCluster(list(self._ribbon_jnts), plane_tran, dr=1.0, mi=2.0, omi=True)
try:
libSkinning.assign_weights_from_segments(self._ribbon_shape, self._ribbon_jnts, dropoff=1.0)
except ZeroDivisionError, e:
pass
示例15: connectLocRotate
def connectLocRotate():
'''
'''
locGrpNames = ['_back',
'_left',
'_front',
'_right',
'_leftBack',
'_rightBack',
'_rightFront',
'_leftFront']
# create one nurb circle for all groups
circ = pm.createNode('makeNurbCircle', n='CT_jacketLocsAlign_circle')
circ.normal.set(0,1,0)
# use the same root ctrl for all groups
rootCtl = pm.PyNode('Mathilda_root_ctrl')
# create one motionpath for each group
for grpName in locGrpNames:
mp = pm.createNode('motionPath', n='CT_jacketLocsAlign'+grpName+'_mp')
circ.outputCurve >> mp.gp
# use paramater from lowest npc
pm.PyNode('torsoReader_3'+grpName+'_npc').parameter >> mp.uValue
rootCtl.worldMatrix >> mp.worldUpMatrix
mp.worldUpType.set(2)
mp.worldUpVector.set(0,1,0)
mp.frontAxis.set(0)
mp.upAxis.set(1)
# connect to all locs in grp
for locId in range(1,10):
mp.rotate >> pm.PyNode('torsoReader_%d%s_loc.r' %
(locId, grpName))