def joint(side, lowerJoint, upperJoint, useSphere=0, sharedUpper=0, sharedLower=0, show=1, heightScale=1): name = lowerJoint + "_" + upperJoint upperName = "SKEL_" if sharedUpper == 0: upperName += side + "_" upperName += upperJoint lowerName = "SKEL_" if sharedLower == 0: lowerName += side + "_" lowerName += lowerJoint print name cmds.spaceLocator(name="%s_%s" % (side, name)) cmds.pointConstraint(lowerName, "%s_%s" % (side, name)) cmds.pointConstraint(upperName, "%s_%s" % (side, name)) cmds.aimConstraint(upperName, "%s_%s" % (side, name)) if useSphere: cmds.sphere(name="%s_%s_C" % (side, name), radius=1) else: cmds.cylinder(name="%s_%s_C" % (side, name), radius=0.5, heightRatio=6 * heightScale) cmds.setAttr("%s_%s_C.doubleSided" % (side, name), 0) if show == 0: cmds.setAttr("%s_%s_C.primaryVisibility" % (side, name), 0) # cmds.rotate( 0, 0, 90, '%s_FOREARM_C' % (side) ) # cmds.makeIdentity( '%s_FOREARM_C' % (side), apply = 1, rotate = 1 ) cmds.select("%s_%s" % (side, name), "%s_%s_C" % (side, name)) cmds.parentConstraint() return
def arrow(nam, centre, direcn): l = 1 cmds.select(clear=1) cmds.cylinder(name=nam + 'cy') cmds.scale(l, 0.1, 0.28) cmds.polyCone(name=nam + '_co', rcp=1, ax=[1, 0, 0]) #cmds.rotate(90,0,0) cmds.scale(0.5, 0.1, 0.5) cmds.move(l + 0.5, 0, 0) cmds.select(nam + 'cy', add=1) cmds.group(name=nam + '_g') cmds.sets(forceElement='blinn5SG') x, y, z = centre angles = map(lambda x: math.degrees(math.atan(x)), direcn) a, b, c = direcn r = math.sqrt(a**2 + b**2 + c**2) if a < 0: a, b, c = -a, -b, -c #a,b,c=a/r,b/r,c/r #print a,b,c if math.sqrt(a**2 + b**2) == 0.0 and c > 0: b1 = 90 elif math.sqrt(a**2 + b**2) == 0.0 and c < 0: b1 = -90 elif c == 0: b1 = 0.0 else: #print math.sqrt(a**2+b**2) b1 = math.degrees(math.atan(c / math.sqrt(a**2 + b**2))) if a == 0 and b > 0: c1 = 90 elif a == 0 and b < 0: c1 = -90 elif b == 0: c1 = 0 else: c1 = math.degrees(math.atan(b / a)) print b1, c1 if c1 <= 0: c1 = 180 + c1 lant = 0 if a > 0 and c < 0: b1 = -(180 - b1) lant = 1 cmds.rotate(0, -b1, c1) b1 = (math.pi / 180) * b1 c1 = (math.pi / 180) * c1 l = 1.5 * l x1, y1, z1 = l * math.cos(b1) * math.cos(c1), l * math.cos(b1) * math.sin( c1), l * math.sin(b1) #print x1,y1,z1 #cmds.move(x+x1,y+y1,z+z1) if lant == 1: cmds.move(x + x1 / 2 - 0.438, y + y1 / 2 + 0.038, z + z1 / 2) else: cmds.move(x + x1 / 2 - 0.438, y + y1 / 2 + 0.038, z + z1 / 2)
def createCircleControl(name=None, x=1, y=1, z=1, radius=1, color=None, type='strip', heightRatio=0.007): if not name: name = 'circle_CTRL' xform = cmds.group(name=name, em=1) circleShapes = [] circleTransforms = [] vectors = getAxisWorldVectors(xform) xyz = [x,y,z] for i in range(0, len(xyz)): if xyz[i]: circ = None if type == 'curve': circ = cmds.circle(radius=radius, name='jointMoverAxisCtrl', normal=vectors[i], sections=1, ch=0) if color: cmds.color(circ, ud=color) if type == 'strip' or type == 'toroid': circ = None if type == 'strip': circ = cmds.cylinder(radius=radius, name='jointMoverAxisCtrl', axis=vectors[i], sections=7, ch=0, heightRatio=heightRatio) elif type == 'toroid': circ = cmds.torus(radius=radius, name='jointMoverAxisCtrl', axis=vectors[i], sections=7, ch=0, heightRatio=heightRatio) if color: if color == 'xyz': if i == 0: colorControl(circ, name='red_m', color=(1,0,0)) if i == 1: colorControl(circ, name='green_m', color=(0,1,0)) if i == 2: colorControl(circ, name='blue_m', color=(0,0,1)) else: if len(color) == 3: colorControl(circ, color=color) circleShapes.append(cmds.listRelatives(circ[0], fullPath=1, shapes=1)[0]) circleTransforms.append(circ[0]) cmds.parent(circleShapes, xform, r=1, s=1) cmds.delete(circleTransforms) return xform
def createArrow(name=None, thickness=0.1, length=2, vector=[1,0,0], point=[0,0,0]): ''' Creates an arrow in the direction of the vector Example: arrow = createArrow(vector=[0,1,0], length=4) ''' if not name: name = 'arrow_CTRL' #calc length for thickness ratio = length/thickness cyl = cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[length/2, 0, 0], ch=0)[0] cone = cmds.cone(radius=thickness*2, sections=4, ch=0, pivot=(length*1.0005,0,0))[0] xform = cmds.createNode('transform', ss=1, name=name) shapes = [] transforms = [] for node in [cone,cyl]: shapes.append(cmds.listRelatives(node, fullPath=1, shapes=1)[0]) transforms.append(node) cmds.parent(shapes, xform, r=1, s=1) rotateBy = cmds.angleBetween(euler=True, v1=(1,0,0), v2=vector) cmds.rotate(rotateBy[0], rotateBy[1], rotateBy[2], xform) cmds.xform(xform, t=point) cmds.delete(transforms) return xform
def createArrow(name=None, thickness=0.1, length=2, vector=[1, 0, 0], point=[0, 0, 0]): ''' Creates an arrow in the direction of the vector Example: arrow = createArrow(vector=[0,1,0], length=4) ''' if not name: name = 'arrow_CTRL' #calc length for thickness ratio = length / thickness cyl = cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[length / 2, 0, 0], ch=0)[0] cone = cmds.cone(radius=thickness * 2, sections=4, ch=0, pivot=(length * 1.0005, 0, 0))[0] xform = cmds.createNode('transform', ss=1, name=name) shapes = [] transforms = [] for node in [cone, cyl]: shapes.append(cmds.listRelatives(node, fullPath=1, shapes=1)[0]) transforms.append(node) cmds.parent(shapes, xform, r=1, s=1) rotateBy = cmds.angleBetween(euler=True, v1=(1, 0, 0), v2=vector) cmds.rotate(rotateBy[0], rotateBy[1], rotateBy[2], xform) cmds.xform(xform, t=point) cmds.delete(transforms) return xform
def createLRA(node=None, matrix=None, name=None, color=True, thickness=0.1, length=2, vector=[1,0,0], point=[0,0,0], arrowRadiusMult=2): ''' Creates an LRA at the origin, or at a node, or a mmx Example: createLRA(length=2, thickness=0.05, arrowRadiusMult=3) ''' if not name: name = 'arrow_CTRL' nodes = [] x,y,z = [],[],[] #calc length for thickness ratio = length/thickness xform = cmds.createNode('transform', ss=1, name=name) x.append(cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[length/2, 0, 0], ch=0, axis=[1,0,0])[0]) x.append(cmds.cone(radius=thickness*arrowRadiusMult, sections=4, ch=0, pivot=(length*1.0005,0,0))[0]) y.append(cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[0, length/2, 0], ch=0, axis=[0,1,0])[0]) y.append(cmds.cone(radius=thickness*arrowRadiusMult, sections=4, ch=0, pivot=(0,length*1.0005,0), axis=[0,1,0])[0]) z.append(cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[0, 0, length/2], ch=0, axis=[0,0,1])[0]) z.append(cmds.cone(radius=thickness*arrowRadiusMult, sections=4, ch=0, pivot=(0,0,length*1.0005), axis=[0,0,1])[0]) nodes.extend(x) nodes.extend(y) nodes.extend(z) if color: for node in x: colorControl(node, name='red_m', color=(1,0,0)) for node in y: colorControl(node, name='green_m', color=(0,1,0)) for node in z: colorControl(node, name='blue_m', color=(0,0,1)) shapes = [] transforms = [] for node in nodes: shapes.append(cmds.listRelatives(node, fullPath=1, shapes=1)[0]) transforms.append(node) cmds.parent(shapes, xform, r=1, s=1) rotateBy = cmds.angleBetween(euler=True, v1=(1,0,0), v2=vector) cmds.rotate(rotateBy[0], rotateBy[1], rotateBy[2], xform) cmds.xform(xform, t=point) cmds.delete(transforms) return xform
def joint(side, lowerJoint, upperJoint, useSphere=0, sharedUpper=0, sharedLower=0, show=1, heightScale=1): name = lowerJoint + "_" + upperJoint upperName = 'SKEL_' if sharedUpper == 0: upperName += side + "_" upperName += upperJoint lowerName = 'SKEL_' if sharedLower == 0: lowerName += side + "_" lowerName += lowerJoint print name cmds.spaceLocator(name='%s_%s' % (side, name)) cmds.pointConstraint(lowerName, '%s_%s' % (side, name)) cmds.pointConstraint(upperName, '%s_%s' % (side, name)) cmds.aimConstraint(upperName, '%s_%s' % (side, name)) if useSphere: cmds.sphere(name='%s_%s_C' % (side, name), radius=1) else: cmds.cylinder(name='%s_%s_C' % (side, name), radius=0.5, heightRatio=6 * heightScale) cmds.setAttr('%s_%s_C.doubleSided' % (side, name), 0) if show == 0: cmds.setAttr('%s_%s_C.primaryVisibility' % (side, name), 0) #cmds.rotate( 0, 0, 90, '%s_FOREARM_C' % (side) ) #cmds.makeIdentity( '%s_FOREARM_C' % (side), apply = 1, rotate = 1 ) cmds.select('%s_%s' % (side, name), '%s_%s_C' % (side, name)) cmds.parentConstraint() return
def make_bond2(nam, li1, li2, ref=1): if distance(li1, [0, 0, 0]) > distance(li2, [0, 0, 0]): li1, li2 = li2, li1 x1, y1, z1 = li1 x2, y2, z2 = li2 dx = x2 - x1 dy = y2 - y1 dz = z2 - z1 dist = math.sqrt(dx**2 + dy**2 + dz**2) l = distance(li1, li2) if ref == 2: cmds.cylinder(n=nam.split('_')[0] + '_1_' + nam.split('_')[1]) cmds.scale(l / 2, 0.05, 0.05) cmds.move(0, 0, 0.1) cmds.cylinder(n=nam.split('_')[0] + '_2_' + nam.split('_')[1]) cmds.scale(l / 2, 0.05, 0.05) cmds.move(0, 0, -0.1) #cmds.select(clear=1) #cmds.select(nam+'a') cmds.select(nam.split('_')[0] + '_1_' + nam.split('_')[1], add=1) cmds.group(n=nam) else: cmds.cylinder(n=nam) cmds.scale(l / 2, 0.05, 0.05) cmds.move(dx / 2 + x1, dy / 2 + y1, dz / 2 + z1) theta = math.degrees(math.atan(dz / dx)) phi = math.degrees(math.acos(math.sqrt(dx**2 + dy**2) / l)) print theta, phi cmds.rotate(0, abs(phi), theta)
def make_bond(nam, li1, li2, ref=1): l = distance(li1, li2) if ref == 2: cmds.cylinder(n=nam.split('-')[0] + '_1_' + nam.split('-')[1]) cmds.scale(l / 2, 0.05, 0.05) cmds.move(0, 0, 0.1) cmds.cylinder(n=nam.split('-')[0] + '_2_' + nam.split('-')[1]) cmds.scale(l / 2, 0.05, 0.05) cmds.move(0, 0, -0.1) #cmds.select(clear=1) #cmds.select(nam+'a') cmds.select(nam.split('-')[0] + '_1_' + nam.split('-')[1], add=1) cmds.group(n=nam) else: cmds.cylinder(n=nam) cmds.scale(l / 2, 0.05, 0.05) cmds.sets(forceElement='blinn4SG') if li2[0] > li1[0]: #distance(li1,[0,0,0])> distance(li2,[0,0,0]): x2, y2, z2, x1, y1, z1 = map(float, li1 + li2) else: x1, y1, z1, x2, y2, z2 = map(float, li1 + li2) xm, ym, zm = [(x1 + x2) / 2, (y1 + y2) / 2, (z1 + z2) / 2] #print xm,ym,zm cmds.move(xm, ym, zm) direcn = [x2 - x1, y2 - y1, z2 - z1] a, b, c = direcn #print a,b,c r = math.sqrt(a**2 + b**2 + c**2) if math.sqrt(a**2 + b**2) == 0.0 and c > 0: b1 = 90 elif math.sqrt(a**2 + b**2) == 0.0 and c < 0: b1 = -90 elif c == 0: b1 = 0.0 else: #print math.sqrt(a**2+b**2) b1 = math.degrees(math.atan(c / math.sqrt(a**2 + b**2))) if a == 0 and b > 0: c1 = 90 elif a == 0 and b < 0: c1 = -90 elif b == 0: c1 = 0 else: c1 = math.degrees(math.atan(b / a)) print b1, c1 if c1 <= 0: c1 = 180 + c1 if b1 > -7 and b1 < 0: b1 = -b1 elif b1 > 0 and b1 < 6: b1 = -b1 #if (x1>0 and x2<0) or (X1<0 and x2>0): # b1=b1 print b1, c1 cmds.rotate(0, b1, c1)
def draw_plinth(self): """ Draw the plinth. """ # Is there still a plinth? #column = cmds.cylinder(r=1, heightRatio=1, p=[0,0,0]) set_height = lambda a, b: a / b h = set_height(20, 1.0) make_level = lambda e: cmds.cylinder(r=e, heightRatio=1.0/e, p=[0,0,0]) for e in [5, 6, 7, 8, 9]: level = make_level(e) cmds.move(e/2, 0, 0,level)
hitMPoint = om.MFloatPoint(hitPoint.x, hitPoint.y, hitPoint.z) pArray = [0.0, 0.0] x1 = om.MScriptUtil() x1.createFromList(pArray, 2) uvPoint = x1.asFloat2Ptr() uvSet = None closestPolygon = None uvReturn = meshFn.getUVAtPoint(hitMPoint, uvPoint, om.MSpace.kWorld) uValue = om.MScriptUtil.getFloat2ArrayItem(uvPoint, 0, 0) or False vValue = om.MScriptUtil.getFloat2ArrayItem(uvPoint, 0, 1) or False log.info("Hit! [{0},{1},{2}]".format( hitPoint.x, hitPoint.y, hitPoint.z)) #Use new formatting method #Syntax is wrong here, wont' load #print({'hit'[hitPoint.x,hitPoint.y,hitPoint.z],'source'[raySource.x,raySource.y,raySource.z],'uv'[uValue,vValue]}) mc.spaceLocator(p=(hitPoint.x, hitPoint.y, hitPoint.z)) else: return False #Don't usually wanna return None #test surface = mc.cylinder()[0] loc = mc.spaceLocator() mc.move(8, 6, 3, loc) mc.move(8, 0, 3, surface) mc.delete(mc.aimConstraint(surface, loc)) raySource = mc.xform(loc, q=1, ws=1, t=1) centerPoint = mc.xform(surface, q=1, ws=1, t=1) findSurfaceIntersection(surface, raySource)
def createCircleControl(name=None, x=1, y=1, z=1, radius=1, color=None, type='strip', heightRatio=0.007): if not name: name = 'circle_CTRL' xform = cmds.group(name=name, em=1) circleShapes = [] circleTransforms = [] vectors = getAxisWorldVectors(xform) xyz = [x, y, z] for i in range(0, len(xyz)): if xyz[i]: circ = None if type == 'curve': circ = cmds.circle(radius=radius, name='jointMoverAxisCtrl', normal=vectors[i], sections=1, ch=0) if color: cmds.color(circ, ud=color) if type == 'strip' or type == 'toroid': circ = None if type == 'strip': circ = cmds.cylinder(radius=radius, name='jointMoverAxisCtrl', axis=vectors[i], sections=7, ch=0, heightRatio=heightRatio) elif type == 'toroid': circ = cmds.torus(radius=radius, name='jointMoverAxisCtrl', axis=vectors[i], sections=7, ch=0, heightRatio=heightRatio) if color: if color == 'xyz': if i == 0: colorControl(circ, name='red_m', color=(1, 0, 0)) if i == 1: colorControl(circ, name='green_m', color=(0, 1, 0)) if i == 2: colorControl(circ, name='blue_m', color=(0, 0, 1)) else: if len(color) == 3: colorControl(circ, color=color) circleShapes.append( cmds.listRelatives(circ[0], fullPath=1, shapes=1)[0]) circleTransforms.append(circ[0]) cmds.parent(circleShapes, xform, r=1, s=1) cmds.delete(circleTransforms) return xform
def createLRA(node=None, matrix=None, name=None, color=True, thickness=0.1, length=2, vector=[1, 0, 0], point=[0, 0, 0], arrowRadiusMult=2): ''' Creates an LRA at the origin, or at a node, or a mmx Example: createLRA(length=2, thickness=0.05, arrowRadiusMult=3) ''' if not name: name = 'arrow_CTRL' nodes = [] x, y, z = [], [], [] #calc length for thickness ratio = length / thickness xform = cmds.createNode('transform', ss=1, name=name) x.append( cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[length / 2, 0, 0], ch=0, axis=[1, 0, 0])[0]) x.append( cmds.cone(radius=thickness * arrowRadiusMult, sections=4, ch=0, pivot=(length * 1.0005, 0, 0))[0]) y.append( cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[0, length / 2, 0], ch=0, axis=[0, 1, 0])[0]) y.append( cmds.cone(radius=thickness * arrowRadiusMult, sections=4, ch=0, pivot=(0, length * 1.0005, 0), axis=[0, 1, 0])[0]) z.append( cmds.cylinder(radius=thickness, sections=4, heightRatio=ratio, pivot=[0, 0, length / 2], ch=0, axis=[0, 0, 1])[0]) z.append( cmds.cone(radius=thickness * arrowRadiusMult, sections=4, ch=0, pivot=(0, 0, length * 1.0005), axis=[0, 0, 1])[0]) nodes.extend(x) nodes.extend(y) nodes.extend(z) if color: for node in x: colorControl(node, name='red_m', color=(1, 0, 0)) for node in y: colorControl(node, name='green_m', color=(0, 1, 0)) for node in z: colorControl(node, name='blue_m', color=(0, 0, 1)) shapes = [] transforms = [] for node in nodes: shapes.append(cmds.listRelatives(node, fullPath=1, shapes=1)[0]) transforms.append(node) cmds.parent(shapes, xform, r=1, s=1) rotateBy = cmds.angleBetween(euler=True, v1=(1, 0, 0), v2=vector) cmds.rotate(rotateBy[0], rotateBy[1], rotateBy[2], xform) cmds.xform(xform, t=point) cmds.delete(transforms) return xform
self.l_positions = [] self.d_castReturn = findSurfaceIntersectionFromObjectAxis(surface, obj, axis, maxDistance = castDistance, singleReturn=False) or {} log.debug("2nd castReturn: %s"%self.d_castReturn) if self.d_castReturn.get('hits'): self.closestPoint = distance.returnFurthestPoint(distance.returnWorldSpacePosition(obj),self.d_castReturn.get('hits')) or False self.d_castReturn['hit'] = self.closestPoint return self.d_castReturn except StandardError,error: for kw in [surface,obj,axis,pierceDepth,vector,maxDistance]: log.debug("%s"%kw) raise StandardError, " >> error" return fncWrap(*args, **kws).go() #test surface = str(mc.cylinder()[0]) loc = mc.spaceLocator() mc.move(8,6,3, loc) mc.move(8,0,3, surface) mc.delete(mc.aimConstraint(surface, loc)) raySource = mc.xform(loc, q=1, ws=1, t=1) #unit testing def ut_rayCasterSurfaceFuncCls(surface, raySource, rayDir, maxDistance, obj, axis, vector, singleReturn, axisToCheck, maxIterations, pierceDepth): assert type(surface) in [str], "surface is not a string!" assert type(raySource) in [list,tuple], "error type raySource!" assert type(rayDir) in [list,tuple], "error type rayDir!" assert type(maxDistance) in [int, float], "maxDistance is not int or float!" assert type(obj) in [str], "obj is not a string!" assert type(axis) in [str], "axis is not a string!" assert type(vector) in [bool], "axis is not a bool!"
def cylinder(*args, **kwargs): res = cmds.cylinder(*args, **kwargs) if not kwargs.get('query', kwargs.get('q', False)): res = _factories.maybeConvert(res, _general.PyNode) return res
cmds.setKeyframe() ############################### import maya.cmds as cmds # To create a plugin of type "squash" on the selected object. # First, load the plugin. The deformer command will not autoload # your plugin. Then, select the geometries that you'd like to deform, # and use the deformer command as follows. For example, to deform a # cylinder with a squash: # cmds.cylinder( ax=(0, 1, 0), r=1, hr=10, d=3, s=8, nsp=20, ch=1 ) cmds.select( 'nurbsCylinder1', r=True ) cmds.deformer( type="squash" ) # To query the membership of the deformer # cmds.deformer( 'squash1',q=True, g=True ) # To add additional geometries from your deformer, type: # cmds.select( 'nurbsCylinder1', r=True ) cmds.duplicate() # Result: nurbsCylinder2 # cmds.move( -2.749017, 0, 0, r=True ) cmds.deformer( 'squash1', e=True, g='nurbsCylinder2' )
def testAnimNSurfaceDeleteReload(self): # create an animated Nurbs sphere MayaCmds.sphere(ch=False, name='nSphere') MayaCmds.move(5, 0, 0, relative=True) MayaCmds.select('nSphere.cv[0:1][0:7]', 'nSphere.cv[5:6][0:7]', replace=True) MayaCmds.setKeyframe(time=[1, 24]) MayaCmds.currentTime(12, update=True) MayaCmds.scale(1.5, 1, 1, relative=True) MayaCmds.setKeyframe(time=12) # create an animated Nurbs torus MayaCmds.torus(ch=False, name='nTorus') MayaCmds.move(-5, 0, 0, relative=True) MayaCmds.select('nTorus.cv[0][0:7]', 'nTorus.cv[2][0:7]', replace=True) MayaCmds.setKeyframe(time=[1, 24]) MayaCmds.currentTime(12, update=True) MayaCmds.scale(1, 2, 2, relative=True) MayaCmds.setKeyframe(time=12) # create an animated Nurbs plane # should add the trim curve test on this surface, will be easier # than the rest MayaCmds.nurbsPlane(ch=False, name='nPlane') MayaCmds.move(-5, 5, 0, relative=True) MayaCmds.select('nPlane.cv[0:3][0:3]', replace=True) MayaCmds.setKeyframe(time=1) MayaCmds.currentTime(12, update=True) MayaCmds.rotate(0, 0, 90, relative=True) MayaCmds.setKeyframe(time=12) MayaCmds.currentTime(24, update=True) MayaCmds.rotate(0, 0, 90, relative=True) MayaCmds.setKeyframe(time=24) # create an animated Nurbs cylinder MayaCmds.cylinder(ch=False, name='nCylinder') MayaCmds.select('nCylinder.cv[0][0:7]', replace=True) MayaCmds.setKeyframe(time=[1, 24]) MayaCmds.currentTime(12, update=True) MayaCmds.move(-3, 0, 0, relative=True) MayaCmds.setKeyframe(time=12) # write it out to Abc file and load back in self.__files.append(util.expandFileName('testNSurfaceReload.abc')) MayaCmds.AbcExport(j='-fr 1 24 -root nSphere -root nTorus -root nPlane -root nCylinder -file ' + self.__files[-1]) # load back the Abc file, delete the torus and save to a maya file MayaCmds.AbcImport(self.__files[-1], mode='open') MayaCmds.delete('nTorus') self.__files.append(util.expandFileName('test.mb')) MayaCmds.file(rename=self.__files[-1]) MayaCmds.file(save=True) # import the saved maya file to compare with the original scene MayaCmds.file(self.__files[-1], open=True) MayaCmds.select('nSphere', 'nPlane', 'nCylinder', replace=True) MayaCmds.group(name='ReloadGrp') MayaCmds.AbcImport(self.__files[-2], mode='import') surfaceList = MayaCmds.ls(type='nurbsSurface') self.failUnlessEqual(len(surfaceList), 7) surfaces = [('|nSphere|nSphereShape', '|ReloadGrp|nSphere|nSphereShape'), ('|nPlane|nPlaneShape', '|ReloadGrp|nPlane|nPlaneShape'), ('|nCylinder|nCylinderShape', '|ReloadGrp|nCylinder|nCylinderShape')] for s in surfaces: for t in range(1, 25): MayaCmds.currentTime(t, update=True) if not util.compareNurbsSurface(s[0], s[1]): self.fail('%s and %s are not the same at frame %d' % (s[0], s[1], t))
dataFromUser = input (‘Please enter number only’) print (dataFromUser) if dataFromUser >= 50 mx.nurbsCube () else: mx.sphere() import maya.cmds as mx dataFromUser = input (‘Please enter number only’) print (dataFromUser) if dataFromUser = =1: mx.nurbsCube() elif dataFromUser = =2: mx.sphere() elif dataFromUser = =3: mx.cylinder() elif dataFromUser = =4: mx.cone() elif dataFromUser = =5: mx.torus() else: mx. plane() 2nd Part The For Loop EX. import maya.cmds as mx for i in range (1 , 10): print (‘this is i = ’str(i)) Make box and move EX. import maya.cmds as mx # your name nameOfItems = [‘Box2’ , ‘Box3’ , ‘Box4’ , ‘Box5’]