本文整理汇总了Python中maya.cmds.createNode函数的典型用法代码示例。如果您正苦于以下问题:Python createNode函数的具体用法?Python createNode怎么用?Python createNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createNode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: aimObjectConnect
def aimObjectConnect( targets ):
for i in range( len( targets ) -1 ):
first = targets[i]
second = targets[i+1]
grp = cmds.createNode( 'transform', n=second+'_aimObj_GRP' )
trg = cmds.createNode( 'transform', n=second+'_aimObj' )
cmds.parent( trg, grp )
constraint( first, grp )
localMtx = cmds.createNode( 'multMatrixDecompose', n=second+'_localMtx' )
fbfMtx = cmds.createNode( 'fourByFourMatrix', n=second+'_fbfMtx' )
shdOrt = cmds.createNode( 'shoulderOrient', n=second+'_shdOrt' )
cmds.connectAttr( second+'.wm', localMtx+'.i[0]' )
cmds.connectAttr( first+'.wim', localMtx+'.i[1]' )
cmds.connectAttr( localMtx+'.otx', fbfMtx+'.i00' )
cmds.connectAttr( localMtx+'.oty', fbfMtx+'.i01' )
cmds.connectAttr( localMtx+'.otz', fbfMtx+'.i02' )
cmds.connectAttr( fbfMtx+'.output', shdOrt+'.inputMatrix' )
cmds.connectAttr( shdOrt+'.outAngleX', trg+'.rx' )
cmds.connectAttr( shdOrt+'.outAngleY', trg+'.ry' )
cmds.connectAttr( shdOrt+'.outAngleZ', trg+'.rz' )
示例2: createSplineCurveInfo
def createSplineCurveInfo( curve, number, **options ):
crvShape = cmds.listRelatives( curve, s=1 )
if not crvShape: return None
crvShape = crvShape[0]
splineNode = cmds.createNode( 'splineCurveInfo', n=curve+'_spline' )
cmds.connectAttr( crvShape+'.local', splineNode+'.inputCurve' )
if number <= 1:
return None
elif number > 1:
eachRate = 1.0/(number-1)
for i in range( number ):
cmds.setAttr( splineNode+'.parameter[%d]' % i, eachRate*i+0.001 )
for i in range( number-1 ):
trNode = cmds.createNode( 'transform' )
cmds.connectAttr( splineNode+'.output[%d].position' % i, trNode+'.t' )
cmds.connectAttr( splineNode+'.output[%d].rotate' % i, trNode+'.r' )
cmds.parent( trNode, curve )
cmds.setAttr( trNode+'.dh', 1 )
cmds.setAttr( trNode+'.dla', 1 )
return splineNode
示例3: create_line_from_2_obj
def create_line_from_2_obj(self, obja, objb, crv_name='_curve_CRV'):
'''
Desc:
Make a line between 2 objects
Parameter:
crv_name = name of curve
pta = first object
ptb = second object
Return: Curve name
'''
# Define generic curve
curve=cmds.curve(d=1, p=[(0,0,0),(0,0,0)], k=[0,1], n=crv_name)
cmds.setAttr(curve+'.overrideEnabled',1)
cmds.setAttr(curve+'.overrideColor', 13)
# Making connection in worldSpace using decomposeMatrix
dMa=cmds.createNode('decomposeMatrix', n='_DMAT')
dMb=cmds.createNode('decomposeMatrix', n='_DMAT')
# Connect control worldMatrix to decomposeMatrix.inputMatrix
KstMaya.node_op(obja+'.worldMatrix','>>', dMa+'.inputMatrix')
KstMaya.node_op(dMa+'.outputTranslate','>>',curve+'.controlPoints[0]')
KstMaya.node_op(objb+'.worldMatrix','>>', dMb+'.inputMatrix')
KstMaya.node_op(dMb+'.outputTranslate','>>',curve+'.controlPoints[1]')
return curve
示例4: neckMiddleCtlSet
def neckMiddleCtlSet(self):
self.neckMiddleCtl = rigbase.Controler( n='NeckMiddle_CTL' )
self.neckMiddleCtl.setShape( normal=[0,1,0], radius = .5 )
self.neckMiddleCtl.setColor( 29 )
self.middlePoint1 = rigbase.Transform( n='NeckMiddle_spline_Point1' )
self.middlePoint2 = rigbase.Transform( n='NeckMiddle_spline_Point2' )
self.middlePoint1.setParent( self.neckMiddleCtl )
self.middlePoint2.setParent( self.neckMiddleCtl )
rigbase.transformDefault( self.middlePoint1, self.middlePoint2 )
midPnt1Dist= cmds.createNode( 'distanceBetween', n='NeckMiddle_spPnt1_dist' )
midPnt2Dist = cmds.createNode( 'distanceBetween', n='NeckMiddle_spPnt2_dist' )
midMult1Dist = cmds.createNode( 'multDoubleLinear', n='NeckMiddle_md1' )
midMult2Dist = cmds.createNode( 'multDoubleLinear', n='NeckMiddle_md2' )
cmds.setAttr( midMult1Dist+'.input2', -.4 )
cmds.setAttr( midMult2Dist+'.input2', .4 )
cmds.connectAttr( self.neckMiddleInit+'.m', midPnt1Dist+'.inMatrix1' )
cmds.connectAttr( self.headInit+'.m', midPnt2Dist+'.inMatrix2' )
cmds.connectAttr( midPnt1Dist+'.distance', midMult1Dist+'.input1' )
cmds.connectAttr( midPnt2Dist+'.distance', midMult2Dist+'.input1' )
cmds.connectAttr( midMult1Dist+'.output', self.middlePoint1+'.ty' )
cmds.connectAttr( midMult2Dist+'.output', self.middlePoint2+'.ty' )
attrEdit = rigbase.AttrEdit( self.neckMiddleCtl.name )
attrEdit.lockAndHideAttrs( 'sx','sy','sz','v' )
self.rigInstance.neckMiddleCtl = self.neckMiddleCtl.name
示例5: perform
def perform(**kwargs):
sel = cmds.ls(sl=True)
sel3=[]
for s in sel:
sel3+=cmds.xform(s,q=True, ws=True, t=True)
pointset=[]
for i in xrange(len(sel3)/3):
pointset+=[Vector(sel3[i*3],sel3[i*3+1],sel3[i*3+2])]
bbox = BBox()
bbox.obbFromPointSet(pointset)
t = Transform(bbox.axis[0],bbox.axis[1],bbox.axis[2])
t = t.transpose()
z = t.getEuler()
cube = cmds.createNode("polyCube")
cubeShape = cmds.createNode("mesh")
cubeTrans = cmds.listRelatives(cubeShape,p=True)[0]
cmds.connectAttr(cube+".output",cubeShape+".inMesh")
cmds.setAttr(cubeTrans+".tx",bbox.center[0])
cmds.setAttr(cubeTrans+".ty",bbox.center[1])
cmds.setAttr(cubeTrans+".tz",bbox.center[2])
cmds.setAttr(cubeTrans+".rz",degrees(z[2]))
cmds.setAttr(cubeTrans+".ry",degrees(z[1]))
cmds.setAttr(cubeTrans+".rx",degrees(z[0]))
cmds.setAttr(cube+".width",bbox.max[0]-bbox.min[0])
cmds.setAttr(cube+".height",bbox.max[1]-bbox.min[1])
cmds.setAttr(cube+".depth",bbox.max[2]-bbox.min[2])
cmds.sets(e=True,forceElement="initialShadingGroup")
cmds.select(sel)
示例6: getRetargetNode_for
def getRetargetNode_for( self, target ):
retargetBlenderCons = cmds.listConnections( target, s=1, d=0, type='retargetBlender' )
if not retargetBlenderCons:
retargetBlender = cmds.createNode( 'retargetBlender', n= target+'_retargetBlender' )
sourceName = target.replace( self._targetNS, self._sourceNS )
retargetNode = cmds.createNode( 'retargetTransNode', n= sourceName+'_RTTrans' )
self.blenderToControl( retargetBlender, target )
if cmds.nodeType( target ) == 'joint':
fnc.tryConnect( target+'.jo', retargetBlender+'.orient' )
cmds.connectAttr( retargetNode+'.transMatrix', retargetBlender+'.input[0].transMatrix' )
else:
retargetBlender = retargetBlenderCons[0]
fnc.clearArrayElement( retargetBlender+'.input' )
cuIndex = fnc.getLastIndex( retargetBlender+'.input' )
if cuIndex == -1: cuIndex = 0
retargetTransCons = cmds.listConnections( retargetBlender+'.input[%d].transMatrix ' % cuIndex )
if retargetTransCons: cuIndex += 1
sourceName = target.replace( self._targetNS, self._sourceNS )
retargetNode = cmds.createNode( 'retargetTransNode', n= sourceName+'_RTTrans' )
cmds.connectAttr( retargetNode+'.transMatrix', retargetBlender+'.input[%d].transMatrix' % cuIndex )
return retargetNode
示例7: ik_stretch
def ik_stretch(ikhnd):
'''
'''
jts = cmds.ikHandle(ikhnd, q=True, jl=True)
cu_s = cmds.ikHandle(ikhnd, q=True, c=True)
cu = cmds.listRelatives(cu_s, p=1)[0]
cmds.addAttr(ikhnd, longName='ik_stretch', k=1, defaultValue=1.0, minValue=0.0, maxValue=1.)
dcu = cmds.duplicate(cu, n=cu + '_base_scale')[0]
dcu_s = cmds.listRelatives(dcu, c=1)[0]
cf = cmds.createNode('curveInfo')
dcf = cmds.createNode('curveInfo')
bl = cmds.createNode('blendTwoAttr')
md = cmds.createNode('multiplyDivide')
cmds.connectAttr(cu_s + '.worldSpace', cf + '.inputCurve')
cmds.connectAttr(dcu_s + '.worldSpace', dcf + '.inputCurve')
cmds.connectAttr(dcf + '.arcLength', bl + '.input[0]')
cmds.connectAttr(cf + '.arcLength', bl + '.input[1]')
cmds.connectAttr(ikhnd + '.ik_stretch', bl + '.attributesBlender')
cmds.connectAttr(bl + '.output', md + '.input1X')
cmds.setAttr(md + '.input2X', cmds.getAttr(cf + '.arcLength'), l=1)
cmds.setAttr(md + '.operation', 2)
cmds.setAttr(dcu + '.v', 0)
for j in jts:
cmds.connectAttr(md + '.outputX', j + '.sx')
return dcu
示例8: addAngleDriverAttribute
def addAngleDriverAttribute( sel ):
import sgBFunction_attribute
sgBFunction_attribute.addAttr( sel, ln='angleRate0', cb=1 )
sgBFunction_attribute.addAttr( sel, ln='angleRate1', cb=1 )
sgBFunction_attribute.addAttr( sel, ln='angleRate2', cb=1 )
if cmds.listConnections( sel, s=1, d=0, type='angleDriver' ): return None
selP = cmds.listRelatives( sel, p=1, f=1 )[0]
selName = sel.split( '|' )[-1]
targetDriver = cmds.createNode( 'angleDriver', n= 'angleDriver_' + selName )
mm = cmds.createNode( 'multMatrix', n='mm_' + selName )
base = cmds.createNode( 'transform', n= 'angleBase_' + selName )
base = cmds.parent( base, selP )[0]
cmds.xform( base, ws=1, matrix= cmds.getAttr( sel+'.wm' ) )
cmds.connectAttr( sel+'.wm', mm+'.i[0]' )
cmds.connectAttr( base+'.wim', mm+'.i[1]' )
cmds.connectAttr( mm+'.matrixSum', targetDriver+'.angleMatrix' )
sgBFunction_attribute.addAttr( sel, ln='angleRate0', cb=1 )
sgBFunction_attribute.addAttr( sel, ln='angleRate1', cb=1 )
sgBFunction_attribute.addAttr( sel, ln='angleRate2', cb=1 )
if not cmds.isConnected( targetDriver+'.outDriver0', sel+'.angleRate0' ):
cmds.connectAttr( targetDriver+'.outDriver0', sel+'.angleRate0' )
if not cmds.isConnected( targetDriver+'.outDriver1', sel+'.angleRate1' ):
cmds.connectAttr( targetDriver+'.outDriver1', sel+'.angleRate1' )
if not cmds.isConnected( targetDriver+'.outDriver2', sel+'.angleRate2' ):
cmds.connectAttr( targetDriver+'.outDriver2', sel+'.angleRate2' )
示例9: addModification
def addModification( meshObjs ):
import sgBFunction_attribute
import sgBFunction_dag
meshObjs = sgBFunction_dag.getChildrenMeshExists( meshObjs )
softMod = cmds.deformer( meshObjs, type='softMod' )[0]
ctlGrp = cmds.createNode( 'transform' )
cmds.setAttr( ctlGrp+'.dh', 1 )
dcmp = cmds.createNode( 'decomposeMatrix' )
ctl = cmds.sphere()[0]
ctl = cmds.parent( ctl, ctlGrp )[0]
sgBFunction_attribute.addAttr( ctl, ln='__________', at='enum', enumName = ':Modify Attr', cb=1 )
sgBFunction_attribute.addAttr( ctl, ln='falloffRadius', min=0, dv=1, k=1 )
sgBFunction_attribute.addAttr( ctl, ln='envelope', min=0, max=1, dv=1, k=1 )
cmds.connectAttr( ctlGrp+'.wim', softMod+'.bindPreMatrix' )
cmds.connectAttr( ctlGrp+'.wm', softMod+'.preMatrix' )
cmds.connectAttr( ctl+'.wm', softMod+'.matrix' )
cmds.connectAttr( ctl+'.m', softMod+'.weightedMatrix' )
cmds.connectAttr( ctlGrp+'.wm', dcmp+'.imat' )
cmds.connectAttr( dcmp+'.ot', softMod+'.falloffCenter' )
for i in range( len( meshObjs ) ):
cmds.connectAttr( meshObjs[i]+'.wm', softMod+'.geomMatrix[%d]' % i )
cmds.connectAttr( ctl+'.envelope', softMod+'.envelope' )
cmds.connectAttr( ctl+'.falloffRadius', softMod+'.falloffRadius' )
cmds.xform( ctlGrp, ws=1, t=cmds.getAttr( meshObjs[0]+'.wm' )[-4:-1] )
cmds.select( ctlGrp )
示例10: createAimObjectCmd
def createAimObjectCmd( first, second, third, worldPosition=False ):
aimObjectMatrix = cmds.createNode( 'aimObjectMatrix' )
cmds.connectAttr( first+'.wm', aimObjectMatrix+'.targetMatrix' )
cmds.connectAttr( second+'.wm', aimObjectMatrix+'.baseMatrix' )
if third:
aimObject = third
else:
aimObject = cmds.createNode( 'transform' )
if cmds.nodeType( aimObject ) == 'joint':
try: cmds.setAttr( aimObject+'.jo', 0,0,0 )
except:pass
cmds.connectAttr( aimObjectMatrix+'.outRotate', aimObject+'.r' )
if not third: cmds.parent( aimObject, second )
cmds.setAttr( aimObject+'.t', 0,0,0 )
if worldPosition:
cmds.setAttr( aimObjectMatrix+'.worldSpaceOutput', 1 )
cmds.connectAttr( aimObject+'.pim', aimObjectMatrix+'.parentInverseMatrix' )
cmds.connectAttr( aimObjectMatrix+'.outTranslate', aimObject+'.t' )
cmds.parent( aimObject, w=1 )
return aimObject, aimObjectMatrix
示例11: getWristAngleNode
def getWristAngleNode( target, targetBase=None ):
wristAngleCons = cmds.listConnections( target+'.m', s=0, d=1, type='wristAngle' )
wristAngleNode = ''
if not wristAngleCons:
mmCons = cmds.listConnections( target+'.wm', s=0, d=1, type='multMatrix' )
if mmCons:
wristAngleCons = cmds.listConnections( mmCons[0]+'.o', s=0, d=1, type='wristAngle' )
if wristAngleCons: wristAngleNode = wristAngleCons[0]
else:
wristAngleNode = wristAngleCons[0]
if wristAngleNode: return wristAngleNode
wa = cmds.createNode( 'wristAngle' )
if not targetBase:
targetBase = cmds.listRelatives( target, p=1, f=1 )[0]
cmds.connectAttr( target+'.m', wa+'.inputMatrix' )
else:
mm = cmds.createNode( 'multMatrix' )
cmds.connectAttr( target+'.wm', mm+'.i[0]' )
cmds.connectAttr( targetBase+'.wim', mm+'.i[1]' )
cmds.connectAttr( mm+'.o', wa+'.inputMatrix' )
cmds.select( wa )
return wa
示例12: followMatrixConnection
def followMatrixConnection( ctl, others ):
import sgBFunction_attribute
ctlP = cmds.listRelatives( ctl, p=1 )[0]
followMatrix = cmds.createNode( 'followMatrix' )
mmdc = cmds.createNode( 'multMatrixDecompose' )
cmds.connectAttr( others[0]+'.wm', followMatrix+'.originalMatrix' )
sgBFunction_attribute.addAttr( ctl, ln='_______', at='enum', en='Parent:', cb=1 )
for other in others[1:]:
i = others.index( other ) - 1
cmds.connectAttr( other+'.wm', followMatrix+'.inputMatrix[%d]' % i )
attrName = 'parent' + other.split( '_' )[-1]
print other, attrName
sgBFunction_attribute.addAttr( ctl, ln= attrName, min=0, max=10, k=1 )
cmds.connectAttr( ctl+'.'+attrName, followMatrix+'.inputWeight[%d]' % i )
cmds.connectAttr( followMatrix+'.outputMatrix', mmdc+'.i[0]' )
cmds.connectAttr( ctlP+'.pim', mmdc+'.i[1]' )
cmds.connectAttr( mmdc+'.ot', ctlP+'.t' )
cmds.connectAttr( mmdc+'.or', ctlP+'.r' )
示例13: createWorldBlendTwoMatrixObject
def createWorldBlendTwoMatrixObject( first, second, target = None ):
import sgBFunction_attribute
blMtx = cmds.createNode( 'blendTwoMatrix' )
mmdc = cmds.createNode( 'multMatrixDecompose' )
cmds.connectAttr( first+'.wm', blMtx+'.inMatrix1' )
cmds.connectAttr( second+'.wm', blMtx+'.inMatrix2' )
cmds.connectAttr( blMtx+'.outMatrix', mmdc+'.i[0]' )
if not target: target = cmds.createNode( 'transform' )
cmds.connectAttr( target+'.pim', mmdc+'.i[1]' )
sgBFunction_attribute.addAttr( target, ln='blend', min=0, max=1, dv=0.5, k=1 )
cmds.connectAttr( target+'.blend', blMtx+'.attributeBlender' )
if not cmds.isConnected( mmdc+'.ot', target+'.t' ):
cmds.connectAttr( mmdc+'.ot', target+'.t', f=1 )
if not cmds.isConnected( mmdc+'.or', target+'.r' ):
cmds.connectAttr( mmdc+'.or', target+'.r', f=1 )
if not cmds.isConnected( mmdc+'.os', target+'.s' ):
cmds.connectAttr( mmdc+'.os', target+'.s', f=1 )
if not cmds.isConnected( mmdc+'.osh', target+'.sh' ):
cmds.connectAttr( mmdc+'.osh', target+'.sh', f=1 )
cmds.select( blMtx, target )
return blMtx, target
示例14: chimaAddWingBsh
def chimaAddWingBsh() :
# Add wing blend shapes to bird character
cmd = 'file -import -type "mayaAscii" -rpr "geo_1" -options "v=0" -pr -loadReferenceDepth "all" "Y:/USERS/Peck/projs/chimaWingFold/geo_1.ma";'
mm.eval( cmd )
mc.select( 'wingFoldLFT_bsh' , r=True )
mc.select( 'wingFoldLFT_bsh' , add=True )
cmd = 'blendShape -e -t Eggbert_wings_geo 2 wingFoldLFT_bsh 1 -t Eggbert_wings_geo 3 wingFoldRGT_bsh 1 wings_bls;'
mm.eval( cmd )
rootCtrl = 'Pelvis_Ctrl'
mc.addAttr( rootCtrl , ln='L_wingFoldB' , k=True , min=0 , max=10 )
mc.addAttr( rootCtrl , ln='R_wingFoldB' , k=True , min=0 , max=10 )
lMdv = mc.createNode( 'multDoubleLinear' , n='wingFoldBBshLFT_mdv' )
mc.connectAttr( '%s.L_wingFoldB' % rootCtrl , '%s.i1' % lMdv )
mc.setAttr( '%s.i2' % lMdv , 0.1 )
mc.connectAttr( '%s.o' % lMdv , 'wings_bls.wingFoldLFT_bsh' )
rMdv = mc.createNode( 'multDoubleLinear' , n='wingFoldBBshRGT_mdv' )
mc.connectAttr( '%s.R_wingFoldB' % rootCtrl , '%s.i1' % rMdv )
mc.setAttr( '%s.i2' % rMdv , 0.1 )
mc.connectAttr( '%s.o' % rMdv , 'wings_bls.wingFoldRGT_bsh' )
mc.delete( 'wingFold_bsh' )
mc.delete( 'wingOrig_bsh' )
mc.delete( 'wingFoldLFT_bsh' )
mc.delete( 'wingFoldRGT_bsh' )
示例15: pfxHairScaleConnect
def pfxHairScaleConnect( ctl, hairSystemGrp ):
hairSystems = cmds.listRelatives( hairSystemGrp, c=1, ad=1, type='hairSystem' )
def getMultDoubleLinear( attr ):
multNodes = cmds.listConnections( attr, type='multDoubleLinear', s=1, d=0 )
if not multNodes:
multNode = cmds.createNode( 'multDoubleLinear' )
sgRigAttribute.addAttr( multNode, ln='clumpWidthMult', at='message' )
attrValue = cmds.getAttr( attr )
cmds.setAttr( multNode+'.input1', attrValue )
cmds.connectAttr( multNode+'.output', attr )
return multNode
else:
if not cmds.attributeQuery( 'clumpWidthMult', node=multNodes[0], ex=1 ):
multNode = cmds.createNode( 'multDoubleLinear' )
sgRigAttribute.addAttr( multNode, ln='clumpWidthMult', at='message' )
attrValue = cmds.getAttr( attr )
cmds.setAttr( multNode+'.input1', attrValue )
cmds.connectAttr( multNode+'.output', attr )
return multNode
else:
return multNodes[0]
for hairSystem in hairSystems:
dcmp = cmds.createNode( 'decomposeMatrix' )
multNode = cmds.createNode( 'multDoubleLinear' )
cmds.connectAttr( ctl+'.wm', dcmp+'.imat' )
cmds.connectAttr( dcmp+'.osx', multNode+'.input1' )
cmds.setAttr( multNode+'.input2', cmds.getAttr( hairSystem+'.clumpWidth' ) )
cmds.connectAttr( multNode+'.output', hairSystem+'.clumpWidth' )