本文整理汇总了Python中maya.cmds.curve函数的典型用法代码示例。如果您正苦于以下问题:Python curve函数的具体用法?Python curve怎么用?Python curve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了curve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: maya_move
def maya_move(angular_velocity, time_step):
objects = cmds.ls(sl=True)
if objects == []:
print('* Please select at least an object.')
return
trajectory = cmds.ls('trajectory')
for i, o in enumerate(objects):
x = cmds.getAttr(o + '.translateX')
y = cmds.getAttr(o + '.translateY')
z = cmds.getAttr(o + '.translateZ')
loc = [x, y, z]
state = make_state(loc)
state = simulate_circle(state, angular_velocity, time_step)
old_loc = loc
loc = get_location(state)
cmds.select(o)
cmds.move(loc[0], loc[1], loc[2])
# draw trajectory for the first object
if i == 0:
if trajectory == []:
cv = cmds.curve(point=[old_loc, loc], degree=1)
cmds.rename(cv, 'trajectory')
else:
cmds.curve('trajectory', point=[loc], degree=1, append=True)
# keep all objects selected
cmds.select(objects)
示例2: createCurveaBasedOnLocator
def createCurveaBasedOnLocator( prevLoc, loc, baseName, hrsSys ):
leastSquaresMod = mn.createNode( 'leastSquaresModifier' )
origCurv = crv.Curve( mc.curve( d = 1, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
index = mm.eval( 'getNextFreeMultiIndex( "'+ hrsSys.name +'.inputHair", 0 )' )
origCurv.name = 'spiderWeb_base_'+ baseName + '_' + str( index ) + '_CRV'
mc.rebuildCurve( origCurv.name, rpo = 1, rt = 0, end = 1, kr = 0, kcp = 1, kep = 1, kt =0, s= 4, d = 1, tol = 0.01 )
origCurv.a.intermediateObject.v = 1
controledCurv = origCurv.duplicate()
origCurv.shape.attr( 'worldSpace[0]' ) >> leastSquaresMod.a.inputNurbsObject
prevLoc.attr( 'worldPosition[0]') >> leastSquaresMod.attr( 'pointConstraint[0].pointPositionXYZ' )
leastSquaresMod.attr( 'pointConstraint[0].pointConstraintU' ).v = 0
loc.attr( 'worldPosition[0]') >> leastSquaresMod.attr( 'pointConstraint[1].pointPositionXYZ' )
leastSquaresMod.attr( 'pointConstraint[1].pointConstraintU' ).v = 1
leastSquaresMod.a.outputNurbsObject >> controledCurv.shape.a.create
controledCurv.shape.attr( 'worldMatrix[0]' ) >> leastSquaresMod.a.worldSpaceToObjectSpace
fol = mn.createNode( 'follicle' )
fol.a.restPose.v = 1
fol.a.startDirection.v = 1
fol.a.pointLock.v = 3
fol.a.degree.v = 3
fol.a.sampleDensity.v = 3
fol.a.outHair >> hrsSys.attr( 'inputHair[' + str( index ) + ']' )
hrsSys.attr( 'outputHair[' + str( index ) + ']' ) >> fol.a.currentPosition
controledCurv.shape.attr( 'worldSpace[0]' ) >> fol.a.startPosition
curv = crv.Curve( mc.curve( d = 3, ep = [prevLoc.worldPosition, loc.worldPosition] ) )
curv.name = 'spiderWeb_' + baseName + '_' + str( index ) + '_CRV'
fol.a.outCurve >> curv.a.create
folPar = fol.parent
folPar.name = 'spiderWeb_' + baseName + '_' + str( index ) + '_FOL'
return curv, folPar
示例3: createPoleVector
def createPoleVector(self, prefix=None, distanceScale=2, verbose=False):
print 'Building pole vector...'
if prefix is None:
prefix = self.prefix
# Create Joint Vectors
shoulderIkPos = cmds.xform(self.shoulder, q=True, ws=True, t=True)
shoulderIkVec = OpenMaya.MVector(shoulderIkPos[0], shoulderIkPos[1], shoulderIkPos[2])
elbowIkPos = cmds.xform(self.elbow, q=True, ws=True, t=True)
elbowIkVec = OpenMaya.MVector(elbowIkPos[0], elbowIkPos[1], elbowIkPos[2])
wristIkPos = cmds.xform(self.wrist, q=True, ws=True, t=True)
wristIkVec = OpenMaya.MVector(wristIkPos[0], wristIkPos[1], wristIkPos[2])
# Transpose vectors to correct pole vector translation point
bisectorVec = (shoulderIkVec * 0.5) + (wristIkVec * 0.5)
transposedVec = (elbowIkVec * distanceScale) - (bisectorVec * distanceScale)
ikChainPoleVec = bisectorVec + transposedVec
# Create a pole vector
poleVecCon = self.utils.createBoxControl('%selbowPV' % self.prefix, 0.125)
poleVecPos = [ikChainPoleVec.x, ikChainPoleVec.y, ikChainPoleVec.z]
cmds.xform(poleVecCon, t=poleVecPos)
self.utils.orientSnap(self.elbow, poleVecCon)
# Visualize Vectors and End Points
if verbose:
for vector, letter in zip([bisectorVec, transposedVec, ikChainPoleVec,
shoulderIkVec, elbowIkVec, wristIkVec],
['bisectorVec', 'transposedVec', 'ikChainPoleVec',
'shoulderIk', 'elbowIk', 'wristIk']):
cmds.spaceLocator(n='%sVecLoc' % letter, p=[vector.x, vector.y, vector.z])
cmds.curve(n='%sVecCurve' % letter, degree=1, p=[(0, 0, 0), (vector.x, vector.y, vector.z)])
return poleVecCon
示例4: buildNurbsRibbon
def buildNurbsRibbon(self):
if self.guideSpline:
guideDeg = cmds.getAttr(self.guideSpline + '.degree' )
guideSpan = cmds.getAttr(self.guideSpline + '.spans' )
oneCurvePoints = []
otherCurvePoints = []
for i in xrange(guideDeg + guideSpan):
cvPos = cmds.pointPosition(self.guideSpline + '.cv[' + str(i) + "]", w=True )
newPara = cmds.closestPointOnCurve(self.guideSpline, ip=cvPos, paramU=True) #Find the parameter Value
newParaVal = cmds.getAttr(newPara + ".paramU")
cmds.delete(newPara)
infoNode = cmds.pointOnCurve(self.guideSpline, ch=True, pr=newParaVal) #Now find the Position and tangent!
posy = (cmds.getAttr(infoNode + ".position"))[0] # returns the position
posy = MVector(posy[0],posy[1],posy[2])
normy = (cmds.getAttr(infoNode + ".tangent"))[0]
normy = MVector(normy[0],normy[1],normy[2]) #Use MVector from maya.openMaya
normy = normy.normal()
vertVect = MVector(0,1,0)
sideMove = normy^vertVect #This is the notation for a cross product. Pretty cool. Should be a normal movement
sideMove = sideMove.normal() * 0.5
sideMovePos = posy + sideMove
otherSideMovePos = posy - sideMove
oneCurvePoints.append([sideMovePos[0],sideMovePos[1],sideMovePos[2]])
otherCurvePoints.append([otherSideMovePos[0],otherSideMovePos[1],otherSideMovePos[2]])
oneSideCurve = cmds.curve(editPoint = oneCurvePoints, degree=3)
OtherSideCurve = cmds.curve(editPoint = otherCurvePoints, degree=3)
self.tempConstructionParts.append(oneSideCurve)
self.tempConstructionParts.append(OtherSideCurve)
#Now we loft the surface between the two Curves!
nameStart = nameBase(self.totalMarkerList[0].getName(), self.searchString, "loc", "nbs")
nameStart += "ribbonSurface"
self.guideNurbsRibbon = cmds.loft(oneSideCurve, OtherSideCurve, name = nameStart, constructionHistory = True, uniform = True, close = False, autoReverse = True, degree = 3, sectionSpans = 1, range = False, polygon = 0, reverseSurfaceNormals = True)
self.guideNurbsRibbon = self.guideNurbsRibbon[0]
self.ribbonParts.append(self.guideNurbsRibbon)
示例5: createSquare
def createSquare(*args):
cmds.curve(d=1,p=[(0.5,0,0.5), (-0.5,0,0.5),
(-0.5,0,-0.5),(0.5,0,-0.5),(0.5,0,0.5)],
k=[0,1,2,3,4],per=True)
cmds.scale(2.458224,2.459224,2.459224,r=True)
cmds.select(cl=True)
print 'Created a Nurbs Square'
示例6: createLine
def createLine(_parents, _sceneData = False, _layer = False):
nodes = []
lineCurve = ""
firstTime = True
for obj in _parents:
pos = cmds.xform(obj, q=1, t=1, ws=1)
if firstTime:
lineCurve = cmds.curve(d=1, p=[pos])
nodes.append(lineCurve)
cmds.setAttr(lineCurve+".overrideEnabled", 1)
cmds.setAttr(lineCurve+".overrideDisplayType", 2)
cmds.setAttr(lineCurve+".inheritsTransform", 0)
firstTime = False
else:
cmds.curve(lineCurve, a=True, p=pos)
#Clusters must be added after all the cvs are created.
#Don't ask me why!
for j in range(len(_parents)):
clusterName = _parents[j]+"_CLUSTER"
clusterPoint = cmds.cluster(lineCurve+".cv["+str(j)+"]", n=clusterName)
nodes.append(clusterPoint[1])
#cmds.setAttr(clusterPoint[1]+".visibility", 0)
cmds.parent(clusterPoint[1], _parents[j], a=1)
if(_sceneData):
addToLayer(_sceneData, "hidden", nodes)
if _layer:
addToLayer(_sceneData, _layer, lineCurve)
return nodes
示例7: createCurve
def createCurve(self,*args):
"""
Create curve on locators
"""
prefix = mc.textFieldGrp(self.prefixFld,query=True,text=True)
locators = mc.ls(sl=True,fl=True)
rotations = mc.intFieldGrp(self.rotFld,query=True,v1=True)
#Error checking here: Are locators selected?
if len(locators) == 0:
print '\nSelection is empty. Please select locators.\n'
#create splineIK curve
curve = " "
x = 0
while x < rotations:
for each in locators:
try: #Try to append to existing curve
x_loc = mc.getAttr('%s.localPositionX'%each)
y_loc = mc.getAttr('%s.localPositionY'%each)
z_loc = mc.getAttr('%s.localPositionZ'%each)
mc.curve(curve,a=True,p=(x_loc,y_loc,z_loc) )
except: #If appending fails, means a new curve needs to be created
x_loc = mc.getAttr('%s.localPositionX'%each)
y_loc = mc.getAttr('%s.localPositionY'%each)
z_loc = mc.getAttr('%s.localPositionZ'%each)
curve = mc.curve( p=(x_loc,y_loc,z_loc), n='%s_ikCurve'%prefix )
x = x + 1
示例8: arrowController
def arrowController(name, color = 0, lockAttr = ['sc', 'vi'], lock = True):
cmds.curve(n = name , d = 1, p = [(0, 2, 1),(0, 3, 1),(0, 0, 3), (0, -3, 1), (0, -2, 1), (0, -2, -2), (0, 2, -2), (0, 2, 1), (0, -2, -2), (0, 2, -2), (0, -2, 1)], k = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
cmds.createNode('transform', n = '%s_grp' %name)
#lock Attribute
for attr in lockAttr:
if attr == 'tr':
cmds.setAttr('%s.translateX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.translateY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.translateZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'ro':
cmds.setAttr('%s.rotateX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.rotateY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.rotateZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'sc':
cmds.setAttr('%s.scaleX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.scaleY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.scaleZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'vi':
cmds.setAttr('%s.visibility' %name, lock = lock, keyable = False, channelBox = False)
#color change
shapeNode = cmds.listRelatives(name)
cmds.rename(shapeNode, name + 'Shape')
cmds.setAttr(name + 'Shape.overrideEnabled', 1)
cmds.setAttr(name + 'Shape.overrideColor', color)
cmds.select(name, r = True)
cmds.select('%s_grp' %name, tgl = True)
cmds.parent()
return name
示例9: obj_single_rotate
def obj_single_rotate ():
ctrl_shapes = []
ctrl_shapes.append( mc.curve( p = [( -7.105427357601002e-15, -0.3358735290035888, 0.7361468691490706 ), ( -0.030221345939771993, -0.43042515285533867, 0.6908148502394227 ), ( -0.072472769789524, -0.5107046042608161, 0.6274377144647979 ), ( -0.12400997464880703, -0.5684975545498503, 0.5501319071758723 ), ( -0.12400997464880703, -0.5684975545498503, 0.5501319071758723 ), ( -0.12400997464880703, -0.5684975545498503, 0.5501319071758723 ), ( -0.12400997464880703, -0.5819931861859402, 0.5346306603447717 ), ( -0.12400997464880703, -0.5819931861859402, 0.5346306603447717 ), ( -0.12400997464880703, -0.5819931861859402, 0.5346306603447717 ), ( -0.12400997464880703, -0.5819931861859402, 0.5346306603447717 ), ( -0.08197748359885537, -0.540253001036092, 0.5946770761304137 ), ( -0.04551343522386375, -0.48527382262420815, 0.6467685738089758 ), ( -0.015501246831107096, -0.4192182992656619, 0.6896431286557706 ), ( -0.015501246831107096, -0.4192182992656619, 0.6896431286557706 ), ( -0.015501246831107096, -0.4192182992656619, 0.6896431286557706 ), ( -0.015501246831107096, -0.7077292503941806, 0.43808875481816606 ), ( -0.015501246831107096, -0.80800092168273, -0.016811817720621902 ), ( -0.015501246831107096, -0.6943482219457593, -0.34108941639861884 ), ( -0.015501246831107096, -0.5527220271320061, -0.5148315398676033 ), ( -0.015501246831107096, -0.3348935247151239, -0.6771644412642893 ), ( -0.015501246831107096, -0.1758560186022855, -0.7361468691392242 ), ( -0.015501246831107096, -7.844604263429887e-05, -0.7361468691392242 )], per = False, d = 3, k = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19] ) )
ctrl_shapes.append( mc.curve( p = [( 3.552713678800501e-15, -0.3358735290035959, 0.7361468691490706 ), ( 0.03022134593976844, -0.43042515285534577, 0.6908148502394227 ), ( 0.07247276978952044, -0.5107046042608232, 0.6274377144647979 ), ( 0.12400997464880348, -0.5684975545498574, 0.5501319071758723 ), ( 0.12400997464880348, -0.5684975545498574, 0.5501319071758723 ), ( 0.12400997464880348, -0.5684975545498574, 0.5501319071758723 ), ( 0.12400997464880348, -0.5819931861859473, 0.5346306603447717 ), ( 0.12400997464880348, -0.5819931861859473, 0.5346306603447717 ), ( 0.12400997464880348, -0.5819931861859473, 0.5346306603447717 ), ( 0.12400997464880348, -0.5819931861859473, 0.5346306603447717 ), ( 0.08197748359885182, -0.5402530010360991, 0.5946770761304137 ), ( 0.0455134352238602, -0.48527382262421526, 0.6467685738089758 ), ( 0.015501246831103543, -0.419218299265669, 0.6896431286557706 ), ( 0.015501246831103543, -0.419218299265669, 0.6896431286557706 ), ( 0.015501246831103543, -0.419218299265669, 0.6896431286557706 ), ( 0.015501246831103543, -0.7077292503941877, 0.43808875481816606 ), ( 0.015501246831103543, -0.8080009216827371, -0.016811817720621902 ), ( 0.015501246831103543, -0.6943482219457664, -0.34108941639861884 ), ( 0.015501246831103543, -0.5527220271320132, -0.5148315398676033 ), ( 0.015501246831103543, -0.334893524715131, -0.6771644412642893 ), ( 0.015501246831103543, -0.1758560186022926, -0.7361468691392242 ), ( 0.015501246831103543, -7.844604263433487e-05, -0.7361468691392242 )], per = False, d = 3, k = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19] ) )
ctrl_shapes.append( mc.curve( p = [( 0.0, 0.33587352900359235, 0.7361468691490706 ), ( -0.030221345939764888, 0.4304251528553422, 0.6908148502394227 ), ( -0.07247276978951689, 0.5107046042608197, 0.6274377144647979 ), ( -0.12400997464879993, 0.5684975545498538, 0.5501319071758723 ), ( -0.12400997464879993, 0.5684975545498538, 0.5501319071758723 ), ( -0.12400997464879993, 0.5684975545498538, 0.5501319071758723 ), ( -0.12400997464879993, 0.5819931861859438, 0.5346306603447717 ), ( -0.12400997464879993, 0.5819931861859438, 0.5346306603447717 ), ( -0.12400997464879993, 0.5819931861859438, 0.5346306603447717 ), ( -0.12400997464879993, 0.5819931861859438, 0.5346306603447717 ), ( -0.08197748359884827, 0.5402530010360955, 0.5946770761304137 ), ( -0.045513435223856646, 0.4852738226242117, 0.6467685738089758 ), ( -0.01550124683109999, 0.41921829926566545, 0.6896431286557706 ), ( -0.01550124683109999, 0.41921829926566545, 0.6896431286557706 ), ( -0.01550124683109999, 0.41921829926566545, 0.6896431286557706 ), ( -0.01550124683109999, 0.7077292503941841, 0.43808875481816606 ), ( -0.01550124683109999, 0.8080009216827335, -0.016811817720621902 ), ( -0.01550124683109999, 0.6943482219457628, -0.34108941639861884 ), ( -0.01550124683109999, 0.5527220271320097, -0.5148315398676033 ), ( -0.01550124683109999, 0.33489352471512746, -0.6771644412642893 ), ( -0.01550124683109999, 0.17585601860228905, -0.7361468691392242 ), ( -0.01550124683109999, 7.844604263078215e-05, -0.7361468691392242 )], per = False, d = 3, k = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19] ) )
ctrl_shapes.append( mc.curve( p = [( 3.552713678800501e-15, 0.33587352900359235, 0.7361468691490706 ), ( 0.03022134593976844, 0.4304251528553422, 0.6908148502394227 ), ( 0.07247276978952044, 0.5107046042608197, 0.6274377144647979 ), ( 0.12400997464880348, 0.5684975545498538, 0.5501319071758723 ), ( 0.12400997464880348, 0.5684975545498538, 0.5501319071758723 ), ( 0.12400997464880348, 0.5684975545498538, 0.5501319071758723 ), ( 0.12400997464880348, 0.5819931861859438, 0.5346306603447717 ), ( 0.12400997464880348, 0.5819931861859438, 0.5346306603447717 ), ( 0.12400997464880348, 0.5819931861859438, 0.5346306603447717 ), ( 0.12400997464880348, 0.5819931861859438, 0.5346306603447717 ), ( 0.08197748359885182, 0.5402530010360955, 0.5946770761304137 ), ( 0.0455134352238602, 0.4852738226242117, 0.6467685738089758 ), ( 0.015501246831103543, 0.41921829926566545, 0.6896431286557706 ), ( 0.015501246831103543, 0.41921829926566545, 0.6896431286557706 ), ( 0.015501246831103543, 0.41921829926566545, 0.6896431286557706 ), ( 0.015501246831103543, 0.7077292503941841, 0.43808875481816606 ), ( 0.015501246831103543, 0.8080009216827335, -0.016811817720621902 ), ( 0.015501246831103543, 0.6943482219457628, -0.34108941639861884 ), ( 0.015501246831103543, 0.5527220271320097, -0.5148315398676033 ), ( 0.015501246831103543, 0.33489352471512746, -0.6771644412642893 ), ( 0.015501246831103543, 0.17585601860228905, -0.7361468691392242 ), ( 0.015501246831103543, 7.844604263078215e-05, -0.7361468691392242 )], per = False, d = 3, k = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19] ) )
return ctrl_shapes
示例10: extraController
def extraController(name, color = 0, lockAttr = ['sc', 'vi'], lock = True):
cmds.createNode('transform', n = '%s_grp' %name)
cmds.curve(n = name, d = 1, p =[(-4, 0, -3),(-1, 0, -3),(-1, 0, -2),(-3, 0, -2),(-3, 0, -1), (-1, 0, -1),(-1, 0, 0),(-3, 0, 0),(-3, 0, 1),(-1, 0, 1),(-1, 0, 2),(-4, 0, 2),(-4, 0, -3),(3, 0, -3),(2, 0, -1),(2, 0, 0),(3, 0, 2),(2, 0, 2),(1, 0, 0),(0, 0, 2),(-1, 0, 2),(0, 0, 0),(0, 0, -1),(-1, 0, -3),(0, 0, -3),(1, 0, -1),(2, 0, -3),(3, 0, -3),(3, 0, 2),(-4, 0, 2)], k= [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])
cmds.scale(0.2,0.2,0.2)
for attr in lockAttr:
if attr == 'tr':
cmds.setAttr('%s.translateX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.translateY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.translateZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'ro':
cmds.setAttr('%s.rotateX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.rotateY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.rotateZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'sc':
cmds.setAttr('%s.scaleX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.scaleY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.scaleZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'vi':
cmds.setAttr('%s.visibility' %name, lock = lock, keyable = False, channelBox = False)
shapeNode = cmds.listRelatives(name)
cmds.setAttr('%s.overrideEnabled' %shapeNode[0], 1)
cmds.setAttr('%s.overrideColor' %shapeNode[0], color)
return name
示例11: lollipopController
def lollipopController(name, color = 0, size = [1, 1, 1], lockAttr = ['tr', 'ro', 'sc', 'vi'], lock = True):
#cmds.createNode('transform', n = '%s_grp' %name)
cmds.curve(n = name, d = 1, p = [ (0, 0, 0), (0, 3, 0),(0, 4, 1),(0, 5, 0), (0, 4, -1),(0, 3, 0),(0, 4, 1),(0, 4, -1)], k = [1,2,3,4,5,6,7,8])
cmds.scale(size[0],size[1],size[2])
for attr in lockAttr:
if attr == 'tr':
cmds.setAttr('%s.translateX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.translateY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.translateZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'ro':
cmds.setAttr('%s.rotateX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.rotateY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.rotateZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'sc':
cmds.setAttr('%s.scaleX' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.scaleY' %name, lock = lock, keyable = False, channelBox = False)
cmds.setAttr('%s.scaleZ' %name, lock = lock, keyable = False, channelBox = False)
elif attr == 'vi':
cmds.setAttr('%s.visibility' %name, lock = True, keyable = False, channelBox = False)
shapeNode = cmds.listRelatives(name)
cmds.setAttr('%s.overrideEnabled' %shapeNode[0], 1)
cmds.setAttr('%s.overrideColor' %shapeNode[0], color)
util.group(name, '%s_grp' %name)
return name
示例12: archimedesDouble
def archimedesDouble(loops,spiralDown,gaps,height):
'''
Creates a Archimedes spiral that spirals out then in again
loops : Number of complete turns the spiral should have
spiralDown : Direction of the generated curve
growth : Growth factor
height : Vertical height of the spiral
The curve is created and the required number of control vertices is calculated
along with the fraction of the height each CV needs to be placed. The polar
equation of a Archimedes spiral is r=a+b*theta where a rotates the spiral
and b controls distance between successive turnings. The polar coordinates
are converted to Cartesian form by x=r*math.cos(theta) and y=r*math.sin(theta).
After half the CVs, I reverse the equation to wind the spiral back in. The
direction of the curve can be reversed based on the spiralDown flag.
'''
curve=cmds.curve(p=[(0,0,0)],n='curve_01')
cvNo=int(loops*8)
heightFrac = float(height)/cvNo
for i in range(1,(cvNo/2)+1):
theta=i*(0.25*math.pi)
r=(gaps/(1.8*math.pi))*theta
x=r*math.cos(theta)
y=r*math.sin(theta)
cmds.curve(curve,a=True,p=[(x,i*heightFrac,y)])
for i in reversed(range(0,cvNo/2)):
theta=i*(0.25*math.pi)
r=(gaps/(1.8*math.pi))*theta
x=(r*math.cos(theta))
y=-(r*math.sin(theta))
cmds.curve(curve,a=True,p=[(x,height-i*heightFrac,y)])
if spiralDown==True:
cmds.reverseCurve(curve,ch=0,rpo=1)
示例13: createTemplate
def createTemplate(self , eyeMesh):
# create eye jnt
eyeJnt=[]
if 'L_' in str(eyeMesh):
helpClu = mc.cluster(eyeMesh)[0]
LeyeJnt = mc.joint(p=(0,0,0),name=eyeMesh+'_skin_jnt')
self.fromAtoB(eyeJnt,helpClu,1)
ReyeJnt = mc.mirrorJoint(mirrorYZ=True,mirrorBehavior=False,searchReplace=('L_', 'R_')
eyeJnt.append(LeyeJnt)
eyeJnt.append(ReyeJnt)
else:
self.mayaError('Please select the left eye.')
return eyeJnt
def createEyeRig(self):
if mc.objExists(self.eyeGlobalCtrl) == False:
EyesGlobalCtrl = mc.curve(d=1,p=[(-1.069806, 1.027703, 0),(-1.651954,1.89895,0),(-2.523201,2.481098,0),(-3.550904,2.68552,0),(-4.578607,2.481098,0),(-5.449854,1.89895,0),(-6.032002,1.027703,0),(-6.236424,0,0),(-6.032002,-1.027703,0),(-5.449854 ,-1.89895, 0),(-4.578607,-2.481098,0), (-3.550904,-2.68552,0),(-2.523201, -2.481098, 0),(-1.651954,-1.89895,0),(-1.069806,-1.027703,0),(1.058138,-1.032345,0),(1.642915, -1.907527,0),(2.518098,-2.492305,0),( 3.550443,-2.69765,0),(4.582788,-2.492305,0),(5.45797,-1.907527,0),( 6.042748,-1.032345,0),(6.248093,0,0),(6.042748,1.032345,0),( 5.45797,1.907527,0 ),(4.582788,2.492305,0),( 3.550443,2.69765,0),(2.518098,2.492305,0 ),(1.642915,1.907527,0),(1.058138,1.032345,0),( -1.069806,1.027703,0)],k=[0,1,2,3,4,5,6,7,8,9,10,11,12 ,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],n=self.eyeGlobalCtrl)
L_EyeAimCtrl = mc.curve(d=1,p=[(3.653116 ,0.946994,0), (3.653116 ,0 ,0),( 2.706122, 0, 0) , (3.653116 ,0, 0),(4.600109, 0 ,0) , (3.653116 ,0, 0) , (3.653116 ,-0.946994, 0) ],k=[0, 1, 2 ,3 ,4 ,5 , 6 ],n='L_'+self.eyeAimCtrl)
R_EyeAimCtrl = mc.curve(d=1,p=[(3.653116 ,0.946994,0), (3.653116 ,0 ,0),( 2.706122, 0, 0) , (3.653116 ,0, 0),(4.600109, 0 ,0) , (3.653116 ,0, 0) , (3.653116 ,-0.946994, 0) ],k=[0, 1, 2 ,3 ,4 ,5 , 6 ],n='R_'+self.eyeAimCtrl)
mc.parent(L_EyeAimCtrl , EyesGlobalCtrl)
mc.parent(R_EyeAimCtrl , EyesGlobalCtrl)
self.fastGrp('On' , ['zero','con','sdk'],L_EyeAimCtrl)
self.fastGrp'On' , ['zero','con','sdk'],R_EyeAimCtrl)
zeroGrp = self.fastGrp('On' , ['zero','con','sdk'],EyesGlobalCtrl)[2]
示例14: createCurve
def createCurve(ptList,start,end,group=''):
'''
'''
# Initialize Curves
crvList = []
for pt in ptList:
pos = mc.pointPosition(pt)
curve = mc.curve(p=[pos,pos],d=1)
curve = mc.rename(curve,pt+'_curve')
crvList.append(curve)
# Track Curves
for i in range(start,end+1):
mc.currentTime(i)
for n in range(len(ptList)):
pos = mc.pointPosition(ptList[n])
mc.curve(crvList[n],a=True,p=pos)
# Remove Initial CV and Rebuild
for crv in crvList:
mc.delete(crv+'.cv[0]')
mc.rebuildCurve(crv,ch=False,rpo=True,rt=0,end=1,kr=2,kcp=True,kep=True)
# Group Curves
if group:
# Check Group
if not mc.objExists(group): group = mc.group(em=True,n=group)
# Parent Curves to Group
mc.parent(crvList,group)
# Return Result
if group: return [group]
else: return crvList
示例15: corners
def corners(self):
"""
Create corners control
"""
ctrl = cmds.createNode('transform')
pts = [(0.9, 0.0, 1.0), (1.0, 0.0, 1.0), (1.0, 0.0, 0.9)]
cnr = cmds.curve(d=1, p=pts, k=range(3))
cnrShape = cmds.listRelatives(cnr, s=True, ni=True)[0]
cmds.parent(cnrShape, ctrl, s=True, r=True)
pts = [(-0.9, 0.0, 1.0), (-1.0, 0.0, 1.0), (-1.0, 0.0, 0.9)]
cnr = cmds.curve(d=1, p=pts, k=range(3))
cnrShape = cmds.listRelatives(cnr, s=True, ni=True)[0]
cmds.parent(cnrShape, ctrl, s=True, r=True)
pts = [(0.9, 0.0, -1.0), (1.0, 0.0, -1.0), (1.0, 0.0, -0.9)]
cnr = cmds.curve(d=1, p=pts, k=range(3))
cnrShape = cmds.listRelatives(cnr, s=True, ni=True)[0]
cmds.parent(cnrShape, ctrl, s=True, r=True)
pts = [(-0.9, 0.0, -1.0), (-1.0, 0.0, -1.0), (-1.0, 0.0, -0.9)]
cnr = cmds.curve(d=1, p=pts, k=range(3))
cnrShape = cmds.listRelatives(cnr, s=True, ni=True)[0]
cmds.parent(cnrShape, ctrl, s=True, r=True)
return ctrl