def locatorOnly(self): sel = cmds.ls(sl=True) # Gives error if more than one object is selected. if len(sel) > 1: cmds.error("Too many objects selected!") # Creates and snaps a locator to object. elif len(sel): tObj = sel[0] tLoc = "{0}_tLoc".format(tObj) LScale = cmds.floatField(LocScale, q=True, v=True) if cmds.objExists(tLoc): cmds.delete(tLoc) cmds.spaceLocator(n="{0}_tLoc".format(tObj)) cmds.scale(LScale, LScale, LScale) cmds.parentConstraint(tObj, tLoc, mo=False) cmds.parentConstraint(tObj, tLoc, rm=True) print LScale # Gives error if no objects are selected. else: cmds.error("No objects selected!")
def Box(name='box_cnt',group=False,size=1.0): ''' Creates a box shape. If group is True, will group control and return a list [group,control]. ''' #creating the curve curve=cmds.curve(d=1, p=[(1,1,-1),(1,1,1),(1,-1,1), (1,-1,-1),(1,1,-1),(-1,1,-1), (-1,-1,-1),(-1,-1,1),(-1,1,1), (1,1,1),(1,-1,1),(-1,-1,1), (-1,-1,-1),(1,-1,-1),(1,1,-1), (-1,1,-1),(-1,1,1),(1,1,1), (1,1,-1)]) #naming control node=cmds.rename(curve,name) #sizing cmds.scale(size,size,size,node) cmds.FreezeTransformations(node) #grouping control if group==True: grp=cmds.group(node,n=name+'_grp') return [grp,node] #return return node
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
def pub_spawnPoints(): _sel = mc.ls(sl=True) if len(_sel) > 0: # template the object mc.setAttr ( _sel[0] + ".template", 1) # get object BB and position in worldspace _objBB = mc.xform( _sel[0], q=True, bb=True) _objPos = mc.xform( _sel[0], ws=True, q=True, rp=True) # set the position of the plane under the object _poz = [0, 0, 0] _poz[0] = _objPos[0] _poz[1] = _objPos[1] - (( _objBB[4] - _objBB[1]) / 1.75) _poz[2] = _objPos[2] # scale the plane larger than the bounding box _scale = [0, 0, 0] _scale[0] = ( _objBB[0] - _objBB[3]) * 1.2 _scale[2] = ( _objBB[2] - _objBB[5]) * 1.2 # create, place, scale and rename the plane mc.nurbsPlane( p=(0, 0, 0), ax=(0, 1, 0), w=1, lr=1, d=3, u=1, v=1, ch=0) mc.move( _poz[0], _poz[1], _poz[2]) mc.scale( _scale[0], 0, _scale[2]) _nPlane = mc.rename( "emissionPlane_" + _sel[0] ) # create the emitter mc.emitter( _nPlane, type='surface', r=20, sro=0, nuv=1, cye='none', cyi=1, spd=2, srn=1, nsp=1, tsp=0, mxd=0, mnd=0, sp=0) _emitter = mc.rename( "emitter_" + _sel[0] ) # create the particle object mc.particle( n="xxx") _pParticle = mc.rename( "particle_" + _sel[0] ) # connect the emitter to the particle object mc.connectDynamic( _pParticle, em=_emitter ) # template the plane and the particle object mc.setAttr ( _nPlane + ".template", 1) mc.setAttr ( _pParticle + ".template", 1) else: assert "No object selected!"
def doIt(self, argList): # get objects from argument list (size >= 2) try: obj = misc.getArgObj(self.syntax(), argList) if (len(obj) < 2): cmds.error("Select at least 2 objects!") return if (cmds.objectType(obj[0]) != 'transform' or cmds.objectType(obj[1]) != 'transform'): cmds.error("Object is not of type transform!") return except: cmds.warning("No objects selected or only one object given!") return argData = om.MArgParser(self.syntax(), argList) # read all arguments and set default values keepCD = argData.flagArgumentBool('keepConvexDecomposition', 0) if (argData.isFlagSet('keepConvexDecomposition')) else True nvol = argData.flagArgumentDouble('normVolume', 0) if ( argData.isFlagSet('normVolume')) else 100.0 norm = argData.flagArgumentBool('norm', 0) if ( argData.isFlagSet('norm')) else True s_file = os.path.abspath(argData.flagArgumentString('saveFile', 0)) if (argData.isFlagSet('saveFile')) else "" save = False if s_file != "": o_file = open(s_file, 'w') o_file.write("i0, i1, name0, name1, its_volume, dice\n") save = True # get all flags for vhacd over static parsing method vhacd_par = vhacd.vhacd.readArgs(argData) if (vhacd_par is None): cmds.error("V-HACD: one or more arguments are invalid!") return #norm the volume if norm: for o in obj: v = cmds.getVolume(o) scale_factor = (nvol/ v) ** (1./3) # cmds.xform(o, scale=[scale_factor, scale_factor, scale_factor]) cmds.scale(scale_factor, scale_factor, scale_factor, o, relative=True) cmds.makeIdentity(o, apply=True) intersection_matrix = np.matrix(str(cmds.intersection(obj, kcd=keepCD, matlabOutput=True, **vhacd_par))) dice_matrix = np.matrix(intersection_matrix) for i in range(0, intersection_matrix.shape[0]): for j in range(i, intersection_matrix.shape[1]): its_volume = intersection_matrix[i, j] dice_matrix[i, j] = (its_volume*2)/(intersection_matrix[i, i]+intersection_matrix[j, j]) if save: o_file.write(",".join((str(i), str(j), obj[i], obj[j], str(its_volume), str(dice_matrix[i, j])))) o_file.write("\n") o_file.flush() if save: o_file.close() self.setResult(str(dice_matrix))
def build(self): super(Finger,self).build() #scale down the controls! They're too big! for i in self.mainCtrls: cmds.select( "{0}.cv[*]".format(i.getName()) ) cmds.scale( 0.25 ,0.25 ,0.25 ,r=True) cmds.select(cl=True)
def birth(self, mom): x=2 cmds.polyCube(n=self.name, w=0, h=0, d=0) cmds.scale(self.size-x,self.size-x,self.size-x, absolute = True) p=cmds.pointConstraint(mom, self.name) cmds.delete(p) cmds.parent(self.name, mom)
def setup_scene(name=sys.argv[1]): # imports shirt, scales to fit, converts to ncloth try: cmds.loadPlugin("objExport") except: pass mel.eval('file -f -options "mo=1" -ignoreVersion -typ "OBJ" -o "%s";' \ % name) try: mel.eval('rename "Mesh" "shirt";') except: pass # scale shirt to fit create_table() if (fold_num == 0): bbx = cmds.xform("shirt", q=True, bb=True, ws=True) s_x_len = abs(bbx[3] - bbx[0]) s_y_len = abs(bbx[4] - bbx[1]) global GLOBAL_SCALE if (s_x_len >= s_y_len): GLOBAL_SCALE = s_x_len/(SHIRT_SCALE * TABLE_SIZE) else: GLOBAL_SCALE = s_y_len/(SHIRT_SCALE * TABLE_SIZE) cmds.select("shirt") cmds.move(0, 0.0001, 0, relative = True) cmds.scale(GLOBAL_SCALE, GLOBAL_SCALE, GLOBAL_SCALE, "table", centerPivot = True) shirt_to_nCloth() create_camera()
def Circle(name='circle_cnt',group=False,size=1.0): ''' Creates a circle shape. If group is True, will group control and return a list [group,control]. ''' #creating the curve curve=cmds.circle(radius=1,constructionHistory=False) #transform to standard cmds.rotate(0,90,0,curve) cmds.makeIdentity(curve,apply=True, t=1, r=1, s=1, n=0) #naming control node=cmds.rename(curve,name) #sizing cmds.scale(size,size,size,node) cmds.FreezeTransformations(node) #grouping control if group==True: grp=cmds.group(node,n=name+'_grp') return [grp,node] #return return node
def setUp(self): MayaCmds.file(new=True, force=True) self.__files = [] # write out an animated Alembic file createAnimatedSolarSystem() self.__files.append(util.expandFileName("testAnimatedSolarSystem.abc")) MayaCmds.AbcExport(j="-fr 1 24 -root group1 -root group2 -file " + self.__files[-1]) # write out a static Alembic file that's different than the static scene # created by createStaticSolarSystem() MayaCmds.currentTime(12, update=True) self.__files.append(util.expandFileName("testStaticSolarSystem.abc")) MayaCmds.AbcExport(j="-fr 12 12 -root group1 -root group2 -file " + self.__files[-1]) # write out an animated mesh with animated parent transform node MayaCmds.polyPlane(sx=2, sy=2, w=1, h=1, ch=0, n="polyMesh") MayaCmds.createNode("transform", n="group") MayaCmds.parent("polyMesh", "group") # key the transform node MayaCmds.setKeyframe("group", attribute="translate", t=[1, 4]) MayaCmds.move(0.36, 0.72, 0.36) MayaCmds.setKeyframe("group", attribute="translate", t=2) # key the mesh node MayaCmds.select("polyMesh.vtx[0:8]") MayaCmds.setKeyframe(t=[1, 4]) MayaCmds.scale(0.1, 0.1, 0.1, r=True) MayaCmds.setKeyframe(t=2) self.__files.append(util.expandFileName("testAnimatedMesh.abc")) MayaCmds.AbcExport(j="-fr 1 4 -root group -file " + self.__files[-1]) MayaCmds.file(new=True, force=True)
def implicitSphere(name,group=False,size=1.0): ''' Creates a square shape. If group is True, will group control and return a list [group,control]. ''' #creating the curve curve=cmds.createNode('implicitSphere') curve=cmds.listRelatives(curve,parent=True)[0] #setup curve cmds.makeIdentity(curve,apply=True, t=1, r=1, s=1, n=0) #naming control node=cmds.rename(curve,name) #sizing cmds.scale(size,size,size,node) cmds.FreezeTransformations(node) #grouping control if group==True: grp=cmds.group(node,n=name+'_grp') return [grp,node] #return return node
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
def createIKCtrlsOnJnts(ikCrv, parentCtrl, size=1): ikCVNum = ll.getCurveCVCount(ikCrv) prev=parentCtrl for i in range(1, ikCVNum): clus = mc.cluster('%s.cv[%d]'%(ikCrv, i), n=parentCtrl.replace('masterctrl','ikClus%d')%i) cvPos = mc.xform('%s.cv[%d]'%(ikCrv, i), q=1, ws=1, t=1) mc.select(parentCtrl) meval('wireShape("plus")') ikCtrl = mc.rename(masterCtrl.replace('masterctrl','ikCtrl%d'%i)) mc.xform(ikCtrl, t=cvPos, ws=1) mc.scale(size, size, size, ikCtrl, ocp=1) mc.makeIdentity(ikCtrl, a=1, s=1) mc.parent(ikCtrl, parentCtrl) lsZeroOut(ikCtrl) ctrlPR = lsZeroOut(ikCtrl, 'PR') mc.addAttr(ikCtrl, ln='SPACE', at='bool', k=1) mc.setAttr(ikCtrl+'.SPACE', l=1) mc.addAttr(ikCtrl, ln='parent', at='float', dv=0, min=0, max=1, k=1) mc.addAttr(ikCtrl, ln='master', at='float', dv=1, min=0, max=1, k=1) mc.addAttr(ikCtrl, ln='world', at='float', dv=0, min=0, max=1, k=1) mc.parentConstraint(ikCtrl, clus) cons = mc.parentConstraint(prev, parentCtrl, ctrlPR, mo=1)[0] wal = mc.parentConstraint(cons, q=1, wal=1) if len(wal) > 1: mc.connectAttr(ikCtrl+'.parent', '%s.%s'%(cons, wal[0]), f=1) mc.connectAttr(ikCtrl+'.master', '%s.%s'%(cons, wal[1]), f=1) prev=ikCtrl
def Square(name='square_cnt',group=False,size=1.0): ''' Creates a square shape. If group is True, will group control and return a list [group,control]. ''' #creating the curve curve=cmds.curve(d=1, p=[(0,1,1),(0,1,-1),(0,-1,-1), (0,-1,1),(0,1,1)]) #setup curve cmds.makeIdentity(curve,apply=True, t=1, r=1, s=1, n=0) #naming control node=cmds.rename(curve,name) #sizing cmds.scale(size,size,size,node) cmds.FreezeTransformations(node) #grouping control if group==True: grp=cmds.group(node,n=name+'_grp') return [grp,node] #return return node
def create_controls(self): """Creates the controls for the neck module.""" neck_ctl = self.c.controls('circle') cmds.makeIdentity(neck_ctl, apply=True, t=1, r=1, s=1, n=0, pn=1) shape = cmds.listRelatives(neck_ctl, c=True, type='shape')[0] shape = cmds.rename(shape, '%s%s' % (self.fk_jnts[0], 'Shape')) cmds.parent(shape, self.fk_jnts[0], s=True, r=True) cmds.delete(neck_ctl) cmds.select('%s.cv[0:10]' % shape, r=True) cmds.scale(8, 8, 8) cmds.move(0, 0, 2.5, r=True, os=True, wd=True) cmds.select(cl=True) self.controls['neck'] = self.fk_jnts[0] head_ctl = self.c.controls('circle') self.c.snap_a_to_b(head_ctl, self.result_jnts[-1]) cmds.xform(head_ctl, ro=[0, 0, 90], s=[14, 1, 24]) cmds.select('%s.cv[0:10]' % head_ctl, r=True) cmds.move(12, 0, 0, r=True, os=True, wd=True) head_ctl = cmds.rename(head_ctl, '%s_%s_%s' % (self.side, 'head', self.nc.control)) cmds.makeIdentity(head_ctl, apply=True, t=1, r=1, s=1, n=0, pn=1) cmds.addAttr(head_ctl, ln='FK_Rotation_Space', nn='FK Rotation Space', at='enum', en='Head:Shoulder:Body:Root') cmds.setAttr('%s.FK_Rotation_Space' % head_ctl, e=True, keyable=True) cmds.addAttr(head_ctl, ln='FK_Translation_Space', nn='FKTranslation Space', at='enum', en='Head:Shoulder:Body:Root') cmds.setAttr('%s.FK_Translation_Space' % head_ctl, e=True, keyable=True) self.controls['head'] = head_ctl
def __finaliseCtrl(self): """ This function is in charge for orienting, scaling and zeroing out the control """ self.__aimCtrl() if self.size != 1: shapes = cmds.listRelatives(self.control, shapes=True) for s in shapes: cmds.select("%s.cv[:]" % s) cmds.scale(self.size, self.size, self.size, r=1) cmds.select(clear=True) cmds.delete(self.control, ch=1) if self.group == True: common.insertGroup(self.control) # self.controlGrp = self.__groupHier(self.control) if self.flip == True: self.__flip()
def shapeSize(obj=None, mltp=1): '''\n mltp = size multiplier of shape nodes ''' if obj is None: # make a list from selection obj = cmds.ls(sl=True, l=True) if obj: shapeSize(obj, mltp) else: message('nothing selected') elif type(obj) == list: # no need to accomodate for i in obj: shapeSize(i, mltp) else: # obj must be a single item, make a list obj = [obj] # run the loop on list for item in obj: shape = cmds.listRelatives(item, s=True, f=True) if shape: for node in shape: if 'SharedAttr' not in node: cmds.scale(mltp, mltp, mltp, node + '.cv[*]')
def scaleGeo(): transx = cmds.intField("gTransX", q=True, value=True) transy = cmds.intField("gTransY", q=True, value=True) transz = cmds.intField("gTransZ", q=True, value=True) cmds.scale( transx,transy,transz )
def test_agst(self): # animated geometry, static transform node nodename = 'agst_node' MayaCmds.polyCube(name=nodename) MayaCmds.select(nodename+'.vtx[0:8]') MayaCmds.setKeyframe(time=1.0) MayaCmds.scale(1.5, 1.5, 1.8) MayaCmds.setKeyframe(time=5.0) self.__files.append(util.expandFileName('agst_motionblur_noSampleGeo_Test.abc')) MayaCmds.AbcExport(j='-fr 1 5 -step 0.5 -wfg -root %s -file %s' % ( nodename, self.__files[-1])) # frameRange: 1, 2, 3, 4, 5, 6 self.isFrameRangeTransAndFrameRangeShapeExists(self.__files[-1]) self.__files.append(util.expandFileName('agst_motionblur_Test.abc')) MayaCmds.AbcExport(j='-fr 1 5 -step 0.5 -root %s -f %s' % ( nodename, self.__files[-1])) # frameRange: 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6 self.isFrameRangeExists(self.__files[-1]) self.__files.append(util.expandFileName('agst_noSampleGeo_Test.abc')) MayaCmds.AbcExport(j='-fr 1 5 -wfg -root %s -f %s' % (nodename, self.__files[-1])) # frameRange: 1, 2, 3, 4, 5 self.isFrameRangeExists(self.__files[-1])
def makeTree(shaders): ''' Creates a tree. shaders: A list of shaders for the tree crown. On exit: A tree has been modeled, and is returned as a tuple containing the object name and the node name. Some of the variables are chosen randomly to create different results. ''' height = random.uniform(0.3,1.5) trunk = cmds.polyCylinder(name = "trunk", h = height, r = 0.07) cmds.sets(trunk[0], edit=True, forceElement="trunkMaterialGroup") cmds.xform(trunk, translation = (0,height/2.0 + 0.2,0)) crown = cmds.polySphere(name = "crown", r = 0.5) cmds.xform(crown, translation = (0,height + 0.6,0)) cmds.softSelect(sse = True, ssd = 0.86) cmds.select(crown[0] + ".vtx[381]") translation = random.uniform(0.3,1.5) cmds.move(translation, y = True, r = True) cmds.softSelect(sse = False) shader = random.choice(shaders) scale_ = random.uniform(0.7,1.8) cmds.select(crown) cmds.scale(scale_, scale_, scale_, pivot = (0,height,0)) cmds.sets(crown[0], edit=True, forceElement= shader[1]) tree = cmds.polyUnite(trunk[0],crown[0]) cmds.delete(tree[0], ch = True) return tree
def create_pointer(m): if (BAXER_POINTER == True): # import Baxter Pointer model and use it try: cmds.loadPlugin("objExport") except: pass name = os.path.dirname(os.path.realpath(__file__)) + "/models/baxter_gripper.obj" mel.eval('file -import -type "OBJ" -ignoreVersion -ra true -mergeNamespacesOnClash false -rpr "gripper" -options "mo=1" -pr "%s";' \ % name) try: mel.eval('rename "gripper_Mesh" "pointer' + str(m) + '";') except: pass else: # Create a pointer mesh that represents the robot claw cmds.polyCone(name="pointer" + str(m), sx=3, r=0.5, h=2) cmds.select("pointer" + str(m)) cmds.rotate("180deg", 0, 0, r=True) cmds.move(0, -1, 0, "pointer" + str(m) + ".scalePivot", "pointer" + str(m) + ".rotatePivot") cmds.move(0, 1, 0, absolute=True) cmds.makeIdentity(apply=True, t=1, r=1, s=1) bbx = cmds.xform("table", q=True, bb=True, ws=True) cur_size = abs(bbx[3] - bbx[0]) cmds.scale(cur_size/TABLE_SIZE, cur_size/TABLE_SIZE, cur_size/TABLE_SIZE, "pointer" + str(m), centerPivot = True) mel.eval('select -r pointer' + str(m) + '; sets -e -forceElement pointer_matSG;') mel.eval("makeCollideNCloth")
def Neck_Control(*args, **kwargs): NeckJt = "Neck_Jt" NeckCtrl = [mc.curve(name="Neck_Ctrl",degree=3,point=[(-0.801407, 0, 0.00716748),(-0.802768, 0.023587, -0.220859), (-0.805489, 0.0707609, -0.676912), (0.761595, -0.283043, -0.667253), (1.045492, -0.194522, -0.0218101), (1.046678, -0.194804, 0.0403576),(0.758039, -0.282198, 0.63974), (-0.806291, 0.0676615, 0.650803),(-0.803035, 0.0225538, 0.221713),(-0.801407, 0, 0.00716748)]), mc.setAttr("Neck_Ctrl.overrideColor",18),mc.setAttr("Neck_Ctrl.overrideEnabled",1)] mc.scale(2.1,3.16,2.8) mc.makeIdentity( 'Neck_Ctrl', apply=True, translate=True,scale=True) lockScaling = mc.setAttr("Neck_Ctrl.scale",lock=True) # xform translation valNeck = mc.xform(NeckJt,ws=True,query=True,translation=True) mc.xform(NeckCtrl,ws=1,t = (valNeck[0],valNeck[1],valNeck[2])) mc.orientConstraint("Neck_Ctrl", NeckJt) mc.pointConstraint("Neck_Ctrl", NeckJt) grpNeck = mc.group("Neck_Ctrl", name="GRP_Neck") mc.parent("GRP_Neck","Front_Spine_Ctrl") #Lock translation for curve lockTranslation = mc.setAttr("Neck_Ctrl.translate",lock=True) return NeckCtrl,NeckJt
def createCOG(*args): cmds.circle(nr=(0,1,0),s=16, r=2) cmds.scale(0.177161, 0.177161, 0.177161,'.cv[15]','.cv[13]','.cv[11]','.cv[9]','.cv[7]', '.cv[5]','.cv[3]','.cv[1]',r=True) cmds.scale(1.848257, 1.848257, 1.848257, r=True) cmds.select(cl=True) print 'Created a COG'
def loadSelectedObj(): cmds.file(new=True, pm=False, force=True) selected = cmds.optionMenu(loadComponentsMenu, q=True, v=True) global furniture global furnitureFilePath path = os.path.split(furnitureFilePath)[0] + "/meshes/furniture/" menuItems = cmds.optionMenu(componentsMenu, q=True, itemListLong=True) cmds.textField(objNameInput, tx=selected.split(".")[0].split("/")[1], e=True) if menuItems: cmds.deleteUI(menuItems) for comp in furniture["components"] : if comp["src"] == selected : global currentComponent componentDef = "" with open(os.path.split(furnitureFilePath)[0]+"/"+comp["src"], "r") as componentFile: componentDef = componentFile.read() currentComponent = json.loads(componentDef) cmds.file(path + currentComponent["src"], i=True) for con in currentComponent["connectors"]: #for connectors in the current objects connectors for types in con["componentTypes"]: cmds.menuItem(p=componentsMenu, label=types) for jnt in con["out"]: loc = cmds.spaceLocator() cmds.move(jnt["position"][0], jnt["position"][1], jnt["position"][2], loc) cmds.scale(jnt["scale"][0], jnt["scale"][1], jnt["scale"][2], loc) cmds.rotate(jnt["rotation"][0], jnt["rotation"][1], jnt["rotation"][2], loc) updateJson() selectLocators() cmds.textField(typeInput, tx=currentComponent["type"], e=True)
def createHoneyPiece(n): planeName = 'plane'+str(n) print planeName cmds.polyPlane(w=20, h=20, sx=12, sy=12, n=planeName) edgeNum = 26 modVal = 1; edgeArray = [] for i in range(52): edgeArray.append(planeName+'.e['+str(edgeNum)+']'); edgeNum += 2 if(edgeNum == 51): edgeNum = 101 if(edgeNum==50): edgeNum = 49 if(edgeNum == 126): edgeNum = 176 if(edgeNum==125): edgeNum = 124 if(edgeNum==201): edgeNum = 251 if(edgeNum==200): edgeNum = 199 if(edgeNum==275): edgeNum = 274 cmds.polyBevel(edgeArray, offset=1,offsetAsFraction=1,autoFit=1,segments=1,worldSpace=1,uvAssignment=0,fillNgons=1,mergeVertices=1,mergeVertexTolerance=0.0001,smoothingAngle=30,miteringAngle=180,angleTolerance=180,ch=1) cmds.select( clear=True) print len(edgeArray) del edgeArray[:] print len(edgeArray) for i in range(532, 620): cmds.select(planeName+'.e['+str(i)+']', toggle=True); size = 36; edgeNum = 31 counter = 0 for i in range(size): cmds.select(planeName+'.e['+str(edgeNum)+']', toggle=True); edgeNum += 2 counter += 1 if(counter == 12): counter = 0 edgeNum += 7; cmds.delete(); for i in range(12): cmds.select(planeName+'.f['+str(i)+']', toggle=True); for i in range(96, 108): cmds.select(planeName+'.f['+str(i)+']', toggle=True); for i in range(1,8): cmds.select(planeName+'.f['+str(i*12)+']', toggle=True); for i in range(1,8): cmds.select(planeName+'.f['+str(i*12+11)+']', toggle=True); cmds.delete(); cmds.scale(1, 1, 0.5, planeName); #cmds.select(planeName+'.f[0:113]') cmds.polyExtrudeFacet(planeName+'.f[0:113]', constructionHistory=1, keepFacesTogether=0, pvx=4.7, pvy=-1.058, pvz=2.38, divisions=1, twist=0, taper=1, off=0, thickness=0, smoothingAngle=30) cmds.setAttr("polyExtrudeFace"+str(n*2+1)+".localScale", 0.833333, 0.833333, 0.829938, type="double3") cmds.delete(); cmds.select(planeName+'.f[0:723]') cmds.polyExtrudeFacet(constructionHistory=1, keepFacesTogether=1, pvx=-4.7, pvy=-1.058, pvz=2.38, divisions=1, twist=0, taper=1, off=0, thickness=0, smoothingAngle=30) cmds.setAttr("polyExtrudeFace"+str(n*2+2)+".localTranslate", 0, 0, 1, type="double3")
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'
def testAnimMeshReload(self): MayaCmds.polyCube( name = 'mesh') MayaCmds.setKeyframe('meshShape.vtx[0:7]', time=[1, 24]) MayaCmds.setKeyframe('meshShape.vtx[0:7]') MayaCmds.currentTime(12, update=True) MayaCmds.select('meshShape.vtx[0:7]') MayaCmds.scale(5, 5, 5, r=True) MayaCmds.setKeyframe('meshShape.vtx[0:7]', time=[12]) self.__files.append(util.expandFileName('testAnimMeshReadWrite.abc')) MayaCmds.AbcExport(j='-fr 1 24 -root mesh -f ' + self.__files[-1]) # reading test MayaCmds.AbcImport(self.__files[-1], mode='open') # save as a maya file self.__files.append(util.expandFileName('test.mb')) MayaCmds.file(rename=self.__files[-1]) MayaCmds.file(save=True) # reload as a maya file MayaCmds.file(self.__files[-1], open=True) MayaCmds.AbcImport(self.__files[-2], mode='import') retVal = True mesh1 = '|mesh|meshShape' mesh2 = '|mesh1|meshShape' for t in range(1, 25): MayaCmds.currentTime(t, update=True) if not util.compareMesh( mesh1, mesh2 ): self.fail('%s and %s were not equal at frame %d' % (mesh1, mesh2, t))
def on3DSceneClick(self): if not cmds.window("autorigging_ui", exists=True) : self.resetExternalContext() return if not self.isActive : self.setConsoleText("Vous devez activer l'autorigging.",color=[255,0,0]) return if not self.currentPointKey : self.setConsoleText("Choisissez un type de point a placer.") return pos = cmds.draggerContext("riggingContext", query=1, anchorPoint=1) strPos = "x:"+str(round(pos[0],2)) +"\ny:" + str(round(pos[1],2)) if self.pointsMap[self.currentPointKey]["isSet"] is True : cmds.delete(self.currentPointKey+"sphere") nextObj = cmds.polySphere(name=self.currentPointKey+"sphere", radius=0.3) cmds.move(pos[0], pos[1], 10, nextObj) cmds.scale(1.0,1.0,0.0, nextObj) self.pointsMap[self.currentPointKey]["isSet"] = True self.pointsMap[self.currentPointKey]["clickedPoint"] = pos cmds.button(self.pointsMap[self.currentPointKey]["stateButton"], e=1, backgroundColor=[0,255,0],label=strPos)
def createStalk(self): ''' This method creates the stalk. ''' # y ax is calculated by flower position mc.polyPipe( subdivisionsHeight=3 ); mc.scale( 0.24, self.flowerTY+1, 0.24 ) mc.move( 0, -self.flowerTY/2, 0 ); mc.displaySmoothness( divisionsU=3, divisionsV=3, pointsWire=16, pointsShaded=4, polygonObject=3 ); self.currentStalk = mc.ls( sl=True ); currentStalk0 = self.currentStalk[0] # bend the stalk bendStalkRandomUpX = 1.5 * (1.0 - random.random()) bendStalkRandomUpZ = 1.5 * (1.0 - random.random()) for uCV in range (40,60): mc.select( currentStalk0 + ".vtx[" + str(uCV) + "]" ); mc.move( bendStalkRandomUpX, 0, bendStalkRandomUpZ, r=True ); mc.select( currentStalk0 + ".vtx[" + str(uCV+60) + "]" ); mc.move( bendStalkRandomUpX, 0, bendStalkRandomUpZ, r=True ); bendStalkRandomDownX = 1.2 * (1.0 - random.random()) bendStalkRandomDownZ = 1.2 * (1.0 - random.random()) for uCV in range (20,40): mc.select( currentStalk0 + ".vtx[" + str(uCV) + "]" ); mc.move( bendStalkRandomDownX, 0, bendStalkRandomDownZ, r=True ); mc.select( currentStalk0 + ".vtx[" + str(uCV+100) + "]" ); mc.move( bendStalkRandomDownX, 0, bendStalkRandomDownZ, r=True ) # delete history mc.select( currentStalk0 ) maya.mel.eval( "DeleteHistory" ) mc.select( clear=True ) return self.currentStalk
def cleanup(transform): # Select the transform cmds.select(transform, replace=True) # Scale 1/10x cmds.scale(centerPivot=True, scaleXYZ=1/10) # Freeze transformations cmds.makeIdentity(apply=True, translate=True, rotate=True, scale=True, normal=1)
def main( mmRootFound ): #Grab the root cmds.select( mmRootFound ) #First need to ensure there are no keys in scale because we are adjusting the scale cmds.cutKey( cl = 1, at = ("sx", "sy", "sz") ) #Find the current position and divide by 2.54 (the arbitrary 3dsmax weird value) mmRootScaleX = cmds.getAttr( mmRootFound + '.scaleX') if ( mmRootScaleX != 1 ): #Find the current position and divide by 2.54 (the arbitrary 3dsmax weird value) mmRootTransX = cmds.getAttr( mmRootFound + '.translateX')/2.54 mmRootTransY = cmds.getAttr( mmRootFound + '.translateY')/2.54 mmRootTransZ = cmds.getAttr( mmRootFound + '.translateZ')/2.54 #Set the values to what they should be. cmds.move( mmRootTransX, mmRootTransY, mmRootTransZ, worldSpace = 1, absolute = 1 ) cmds.scale( 1, 1, 1 )
def randgeo(city_grp=None): """ Randomize scale on all geo under group. Args: city_grp: group node containing geo to randomize. If None then get geo from selection. """ if not city_grp: allgeo = cmds.ls(sl=True) else: allgeo = cmds.listRelatives(city_grp, type="transform") for each in allgeo: this_scale = (round(random.uniform(0.5, 1.5), 3), round(random.uniform(0.5, 2.0), 3), round(random.uniform(0.5, 1.5), 3)) cmds.scale(this_scale[0], this_scale[1], this_scale[2], each, scaleXYZ=True, absolute=True)
def addBeams(self, width): cBGroup = cmds.group(em=True) objList = [] xScale = findScale(self.crossHeight, self.crossWidth) for loop in CrossBeams.activeList: beam = cmds.polyCylinder(r=self.crossWidth, h=width - loop["width"] / 3.0, sx=self.sidesNum, ch=False) cmds.rotate(0, 0, 90, beam) cmds.scale(xScale, 1, 1, beam) cmds.move(width / 2.0, (self.crossWidth * xScale) / 2.0 + loop["height"], 0, beam, relative=True) objList.append(beam) cmds.parent(beam, cBGroup) return cBGroup
def build_guide(self): grp = cmds.group(em=1, n=self.loc_grp_name) for i in range(self.segment): spine = cmds.spaceLocator(n=self.loc_list[i]) if i is 0: cmds.parent(spine, grp, relative=1) cmds.move(self.start_pos[0], self.start_pos[1], self.start_pos[2], spine, absolute=1) cmds.scale(self.scale, self.scale, self.scale, spine) else: cmds.parent(spine, self.loc_list[i - 1], relative=1) # move spine locator along +z axis cmds.move(0, 0, self.interval, spine, relative=1) self.color_locator() cmds.parent(grp, self.loc_grp) return grp
def stairs(self, pHr, pWr, pDr, pSt, pSg): pHr = sorted(pHr) pWr = sorted(pWr) pDr = sorted(pDr) h = pHr[1] - pHr[0] w = pWr[1] - pWr[0] d = pDr[1] - pDr[0] d /= pSt staircase = [] #generate staircase step by step and add each step to the staircase list for i in range(pSt): sht = (h / pSt) * i single = h / pSt sh = sht + single / 2 sd = (i + 0.5) * (d) cube = mc.polyCube(h=pSg, n="Stair__" + str(i + 1)) staircase.append(cube) mc.move(w / 2, sh, sd, cube) mc.scale(w, single, d, cube) staircase = mc.polyUnite(*staircase, n="Staircase") return staircase
def build_torus_control(self, **p): n = self.cn + '_ctrl_' + p['prefix'] axis = p['axis'] if 'axis' in p else (0, 1, 0) scale = p['scale'] if 'scale' in p else (1, 1, 1) hr = p['hr'] if 'hr' in p else 0.01 # height ratio r = p['radius'] cmds.torus(ax=axis, ssw=0, esw=360, msw=360, r=r, hr=hr, d=3, ut=0, tol=0.01, s=16, nsp=4, ch=1, n=n) cmds.scale(scale[0], scale[1], scale[2], n, absolute=True) return n
def buildScene(self): MayaCmds.file(new=True, force=True) MayaCmds.namespace(addNamespace='foo') MayaCmds.namespace(addNamespace='bar') MayaCmds.createNode('transform', name='foo:a') MayaCmds.createNode('transform', name='bar:a') MayaCmds.createNode('transform', name='a') MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='foo:b') MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='bar:b') MayaCmds.polyPlane(sx=1, sy=1, w=1, h=1, ch=0, n='b') MayaCmds.parent('foo:b', 'foo:a') MayaCmds.parent('bar:b', 'bar:a') MayaCmds.parent('b', 'a') MayaCmds.select('foo:b.vtx[0:8]') MayaCmds.setKeyframe(t=[1, 4]) MayaCmds.scale(0.1, 0.1, 0.1, r=True) MayaCmds.setKeyframe(t=2) MayaCmds.select('bar:b.vtx[0:8]') MayaCmds.setKeyframe(t=[1, 4]) MayaCmds.scale(2, 2, 2, r=True) MayaCmds.setKeyframe(t=2) MayaCmds.select('b.vtx[0:8]') MayaCmds.setKeyframe(t=[1, 4]) MayaCmds.scale(5, 5, 5, r=True) MayaCmds.setKeyframe(t=2)
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 flakeIterate(base, iterations, angle, scale): ''' Creates a branching iteration of the input branch base : The object to be duplicated iterations : Number of iterations remaining angle : The angle to rotate the branches scale : The amount to scale the duplicated branches A list is made containing the bas object, if there a no more iterations to perform, the list is returned. Otherwise, the length of the base is found and stored as offset and a random length is generated. The first duplicate is made, and positioned at an angle at the end of the base, it is crystallised, then duplicated and mirrored. The base for the next iteration is created and the procedure is called again with one less iteration. A list containing all the objects is returned. ''' list = [base] if iterations == 0: return list bBox = cmds.exactWorldBoundingBox(base) offset = bBox[3] - bBox[0] length = random.uniform(0.2, 3) twig = cmds.duplicate(base)[0] cmds.scale(length, scale, scale, twig, r=1, p=[bBox[0], 0, 0]) cmds.rotate(0, angle, 0, twig, r=1, p=[bBox[0], 0, 0]) cmds.move(offset, 0, 0, twig, r=1) list[len(list):] = [crystalise(twig)] list[len(list):] = [cmds.duplicate(list[-1])[0]] cmds.scale(-1, 1, 1, list[-1]) nextBase = cmds.duplicate(base)[0] cmds.xform(nextBase, sp=[bBox[0], 0, 0], s=[1, scale, scale], t=[offset, 0, 0], r=1) list += flakeIterate(nextBase, iterations - 1, angle, scale) return list
def crystalise(base): ''' Adds hexagonal crystals to a branch base : The branch to be crystallised A crystal is created by scaling the top and bottom rings of vertices of a cylinder. The crystal is aligned to the base branch and scaled to match. The crystal is duplicated, randomly distributed along the branch and scaled relative to their positioning. The crystals are combined with the base branch mesh and this object is returned. ''' crystal = [cmds.polyCylinder(r=1, sx=6, sy=2)[0]] cmds.polySoftEdge(crystal[0], a=0) cmds.scale(0.6, 0.3, 0.6, crystal[0] + '.f[12:13]', r=1) [(tx, ty, tz)] = cmds.getAttr(base + '.translate') [(rx, ry, rz)] = cmds.getAttr(base + '.rotate') cmds.move(tx, ty, tz, crystal[0]) cmds.rotate(rx, ry, rz, crystal[0]) [x1, y1, z1, x2, y2, z2] = cmds.xform(base + '.vtx[0:1]', q=1, t=1, ws=1) baseScale = cmds.getAttr(base + '.scaleX') cmds.scale(0.5, 0.2, 0.5, crystal[0]) length = ((x2 - x1)**2 + (z2 - z1)**2)**0.5 for i in range(0, 6): crystal[len(crystal):] = [cmds.duplicate(crystal[0])[0]] for x in crystal: dist = (random.random()) cmds.move(length * dist, 0, 0, x, os=1, r=1, wd=1) size = (1.5 - dist) * (length / 3) cmds.scale(size, size, size, x, r=1) cmds.rotate(0, 30, 0, x, r=1) crystal += [base] return combineParts(crystal, base)
def build_guide(self): grp = cmds.group(em=1, n=self.loc_grp_name) # Shoulder shoulder = cmds.spaceLocator(n=self.loc_list[0]) cmds.parent(shoulder, grp, relative=1) cmds.move(self.start_pos[0], self.start_pos[1], self.start_pos[2], shoulder, relative=1) cmds.scale(self.scale, self.scale, self.scale, shoulder) # Elbow elbow = cmds.spaceLocator(n=self.loc_list[1]) cmds.parent(elbow, shoulder, relative=1) cmds.move(0, -self.distance, -0.5 * self.distance, elbow, relative=1) # Wrist wrist = cmds.spaceLocator(n=self.loc_list[2]) cmds.parent(wrist, elbow, relative=1) cmds.move(0, -self.distance, 0, wrist, relative=1) # Paw paw = cmds.spaceLocator(n=self.loc_list[3]) cmds.parent(paw, wrist, relative=1) cmds.move(0, -self.distance + self.height, 0.5 * self.distance, paw, relative=1) # Toe toe = cmds.spaceLocator(n=self.loc_list[4]) cmds.parent(toe, paw, relative=1) cmds.move(0, 0, 0.5 * self.distance, toe, relative=1) self.color_locator() cmds.parent(grp, self.loc_grp) return grp
def build_guide(self): grp = cmds.group(em=1, n=self.loc_grp_name) side_factor, horizontal_factor, vertical_factor = 1, 1, 0 if self.side == 'R': side_factor = -1 if self.direction == 'Vertical': horizontal_factor, vertical_factor = 0, 1 # Root limb_root = cmds.spaceLocator(n=self.loc_list[0]) cmds.parent(limb_root, grp, relative=1) cmds.move(self.start_pos[0], self.start_pos[1], self.start_pos[2], limb_root, relative=1) cmds.scale(self.scale, self.scale, self.scale, limb_root) # Middle limb_mid = cmds.spaceLocator(n=self.loc_list[1]) cmds.parent(limb_mid, limb_root, relative=1) cmds.move(self.interval * side_factor * horizontal_factor, -self.interval * vertical_factor, 0, limb_mid, relative=1) # move limb joint along +x axis # Top limb_top = cmds.spaceLocator(n=self.loc_list[2]) cmds.parent(limb_top, limb_mid, relative=1) cmds.move(self.interval * side_factor * horizontal_factor, -self.interval * vertical_factor, 0, limb_top, relative=1) # move limb joint along +x axis # Cleanup self.color_locator() cmds.parent(grp, self.loc_grp) return grp
def makeFlake(branches, radius): ''' Creates a single snowflake branches : number of side branches radius : radius of the snowflake A cube is created and transformed to taper with a diamond cross-section. It is passed to flakeIterate to generate 1/6 of the snowflake. This branch is duplicated and rotated around the centre to create the full snowflake. The parts are combined, the flake is scaled and transformations are frozen. The snowflake name is returned. ''' name = cmds.polyCube()[0] cmds.rotate(45, 0, 0, name, r=1) cmds.move(0.5, 0, 0, name + '.vtx[0:7]', r=1) cmds.scale(0.7, 0.2, 0.1, p=[0, 0, 0], r=1) cmds.scale(1, 0.7, 0.7, name + '.f[4]', r=1, p=[0, 0, 0]) cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) partList = flakeIterate(name, 7, random.uniform(30, 70), 0.7) branches = [combineParts(partList, 'branch')] for i in range(1, 6): branches[len(branches):] = [cmds.duplicate('branch')[0]] cmds.rotate(0, i * 60, 0, branches[-1], r=1) flake = combineParts(branches, 'snowflake') scale = radius / 6 cmds.scale(scale, scale, scale, flake) cmds.makeIdentity(flake, apply=True, s=1, n=0) return flake
def scaleControl(node, scaleVector): """ Scale controlCurve by [x, y, z]. Adjust controlCurve size of node. Args: node: Transform / joint / nurbsCurve node. scaleVector: Scale vector. ocp: Object Center Pivot. Returns: None. Raises: Logs warning if node does not exist. Logs warning if node is not tranform or nurbsCurve type. Logs warning if scaleVector is not a list of three. """ if not cmds.objExists(node): LOG.warning(node + ' does not exist.') return elif not (cmds.objectType(node, isType='transform') or cmds.objectType(node, isType='joint') or cmds.objectType(node, isType='nurbsCurve')): LOG.warning('Input node requires transform, joint or nurbsCurve type.') return elif len(scaleVector) != 3: LOG.warning('Input scaleVector requires a list of three.') return if cmds.objectType(node, isType='nurbsCurve'): cmds.select(cl=1) cmds.select(node + '.cv[:]') cmds.scale(scaleVector[0], scaleVector[1], scaleVector[2], r=1, ocp=0) return shapeList = getShape(node) for shape in shapeList: cmds.select(cl=1) cmds.select(shape + '.cv[:]') cmds.scale(scaleVector[0], scaleVector[1], scaleVector[2], r=1, ocp=0)
def mirrorGeo(): # Variables and selection mirrorMode = cmds.radioButtonGrp('mirrorMode', q=True, sl=True) mDir = cmds.radioButtonGrp('mDir', q=True, sl=True) sel = cmds.ls(sl=True) # Duplication type if (mirrorMode == 1): cmds.duplicate() elif (mirrorMode == 2): cmds.instance() else: newHalf = cmds.duplicate() # Scaling if (mDir == 1): cmds.scale(-1, 1, 1) elif (mDir == 2): cmds.scale(1, -1, 1) else: cmds.scale(1, 1, -1) # Merging Copy if (mirrorMode == 3): cmds.select(sel[0], r=True) cmds.select(newHalf, add=True) cmds.polyUnite() cmds.ConvertSelectionToVertices() cmds.polyMergeVertex(d=0.001, am=1, ch=1) cmds.select(sel[0])
def CtrlCreator(moveX, moveY, moveZ, rotX, rotY, rotZ, scaleX, scaleY, scaleZ): sels = cmds.ls(sl=True) if len(sels) == 0: cmds.circle(name='default_Ctrl') cmds.move(moveX, moveY, moveZ) cmds.rotate(rotX, rotY, rotZ) cmds.scale(scaleX, scaleY, scaleZ) if len(sels) != 0: for i in range(len(sels)): name = sels[i] posX = cmds.getAttr(name + '.translateX') posY = cmds.getAttr(name + '.translateY') posZ = cmds.getAttr(name + '.translateZ') tokens = name.split('_') if len(tokens) == 4: cmds.circle(name=(tokens[0] + '_' + tokens[1] + '_' + tokens[2] + '_Ctrl')) cmds.move(posX, posY, posZ) cmds.rotate(rotX, rotY, rotZ) cmds.scale(scaleX, scaleY, scaleZ) elif len(tokens) != 4: cmds.circle(name=(name + '_Ctrl')) cmds.move(posX, posY, posZ) cmds.rotate(rotX, rotY, rotZ) cmds.scale(scaleX, scaleY, scaleZ)
def generateLeaf(jointPosWorld, planeCnt, jntName): cmds.polySphere(r=0.475) cmds.move(jointPosWorld[0], jointPosWorld[1], jointPosWorld[2]) #xyz values of joint stored in an array cmds.polyPlane(n='leaf'+str(planeCnt), sx=1, sy=3, w=2, h=3) shape = 'leaf' + str(planeCnt) cmds.select(shape + '.e[0]') #selecting the edges and scaling them down to get leaf shape cmds.scale( 0.1, 1, 1 ) cmds.select(shape + '.e[9]') cmds.scale( 0, 1, 1 ) cmds.select(shape) cmds.polySmooth( shape, dv=2, sdt=1) #smooth it out to round out edges cmds.move(0, 0, 1.46, shape + ".scalePivot", shape + ".rotatePivot", absolute=True) cmds.move(jointPosWorld[0], jointPosWorld[1], (jointPosWorld[2] - 1.31)) cmds.aimConstraint( jntName, shape ) cmds.aimConstraint( jntName, shape, rm=True ) cmds.rotate((str((randint(0,180)))) + 'deg', (str((randint(0,180)))) + 'deg', (str((randint(0,180)))) + 'deg', r=True ) cmds.polyExtrudeFacet(ltz=0.1) #extrude the leaf to get rid of null sides #each leaf has a unique size chosen by a random scale value scaleVal = random.uniform(0.8,1.2) cmds.scale( scaleVal, scaleVal, scaleVal )
def wrapIt(self, *args): slMsh = cmds.ls(sl = True) mesh = [] if len(slMsh) >=2: for each in slMsh: cmds.select(each, add=True ) name = each+'_g' importedCombinedMesh = cmds.polyUnite( n=name ) cmds.delete( importedCombinedMesh, ch = True ) mesh.append(name) else: for each in slMsh: cmds.select(each, add=True ) obj = cmds.ls(sl=True) print (obj) name = cmds.rename(obj[0], (each+'_g')) mesh.append(name) bbox = cmds.exactWorldBoundingBox(mesh[0]) x1, y1, z1, x2, y2, z2 = cmds.exactWorldBoundingBox(mesh[0]) lowRes = mesh[0] + '_proxyGeo' proxymesh = cmds.polySphere(n = lowRes, subdivisionsX = 15, subdivisionsY = 15) print proxymesh xc = (x2 + x1) / 2.0 yc = (y2 + y1) / 2.0 zc = (z2 + z1) / 2.0 xw = x2 - x1 yw = y2 - y1 zw = z2 - z1 cmds.move(xc, yc, zc, proxymesh) cmds.scale(xw, yw, zw, proxymesh) shrinkWrapNode = pm.deformer(proxymesh, type='shrinkWrap')[0] pm.PyNode(name).worldMesh[0] >> shrinkWrapNode.targetGeom shrinkWrapNode.closestIfNoIntersection.set(True) cmds.delete( proxymesh, ch = True ) cmds.select(clear = True) cmds.select(proxymesh[0]) cmds.select(mesh[0], add = True) self.copyPivot(mesh[0], proxymesh) return proxymesh[0]
def create_CON_combine_noConnect () : combCON_selPLY = cmds.ls(selection=True) combCON_selPLY_copy = cmds.duplicate (combCON_selPLY) combCON_tempPLY = cmds.polyUnite(combCON_selPLY_copy, mergeUVSets=1, constructionHistory=True, n=combCON_selPLY[0].replace('PLY', 'RE')) cmds.delete (combCON_tempPLY, ch=1) # like a historyDelete and delete emptyGroup, Also Node Check cmds.select (combCON_tempPLY[0]) boundingBox_Info () cmds.select (deselect=1) # CON combCON = cmds.curve (degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) combCON_reName = cmds.rename (combCON_selPLY[0].replace('PLY', 'CON')) combCON_Shape = cmds.listRelatives (combCON_reName, shapes=1) CL.con_overrideColor_SET () combCON_NUL = cmds.group (em=True, n=combCON_selPLY[0].replace('PLY', 'NUL')) cmds.parent (combCON_reName, combCON_NUL) cmds.scale (propRig_bbsX[-1], propRig_bbsY[-1], propRig_bbsZ[-1], combCON_NUL) cmds.move (propRig_bbX_CT[-1], propRig_bbY_CT[-1], propRig_bbZ_CT[-1], combCON_NUL) cmds.makeIdentity (combCON_NUL, apply=1, s=1) con_ChannelBox () cmds.delete (combCON_tempPLY[0]) cmds.parent (combCON_NUL, 'control_GRP') cmds.select (deselect=1)
def instanceRandomizer(currentInstance, RotationRange, ScaleRangeEnd, ScaleRangeStart, PlacementAmountFactor, *pArgs): xRot = random.uniform( 0, RotationRange[0]) # this will be added to UI parameters yRot = random.uniform( 0, RotationRange[1]) # this will be added to UI parameters zRot = random.uniform( 0, RotationRange[2]) # this will be added to UI parameters cmds.rotate(xRot, yRot, zRot, currentInstance) xScale = random.uniform( ScaleRangeStart[0], ScaleRangeEnd[0]) # this will be added to UI parameters yScale = random.uniform( ScaleRangeStart[1], ScaleRangeEnd[1]) # this will be added to UI parameters zScale = random.uniform( ScaleRangeStart[2], ScaleRangeEnd[2]) # this will be added to UI parameters cmds.scale(xScale, yScale, zScale, currentInstance) cmds.xform(currentInstance, centerPivots=True) return currentInstance
def CreateLeaves(self, height, minSize, maxSize): leafBase = cmds.polyPrimitive(r=1, l=1, pt=0)[0] cmds.move(height, y=True) cmds.polyChipOff(dup=False, kft=False) cmds.polyChipOff(dup=False, kft=True, ltz=0.08, ran=1.0) cmds.polyExtrudeFacet(ltz=0.6) cmds.polySmooth() cmds.polySeparate() cmds.xform(cp=True) for leaf in cmds.ls(sl=True): leafScale = round(random.uniform(minSize, maxSize), 3) cmds.select(leaf) cmds.polySoftEdge(a=0, name=leaf) cmds.scale(leafScale, leafScale, leafScale) leafPosition = cmds.xform(leaf, q=True, rp=True, ws=True) leafPosition[1] = height + 0.5 * (height - leafPosition[1]) cmds.xform(leaf, t=leafPosition, ws=True) self.SetRandomLeafColor(leaf) return leafBase
def scale(componentList=[], scale=(1.0, 1.0, 1.0), pivot='center', userPivot=(0, 0, 0), worldSpace=False): """ Scale the specified components based on the input argument values. @param componentList: List of components to scale @type componentList: list @param scale: Scale to apply to the component list @type scale: tuple @param pivot: Pivot option for scale. Valid pivot options are "object", "center" and "user". @type pivot: str @param userPivot: Pivot position to use if the pivot option is set to "user". @type userPivot: tuple @param worldSpace: Perform scaling about global world-space axis. @type worldSpace: bool """ # Check componentList if not componentList: componentList = cmds.ls(componentList, fl=True) # Determine rotation pivot piv = (0, 0, 0) if pivot == 'center': piv = getCenter(componentList) elif pivot == 'object': shape = cmds.listRelatives(componentList[0], p=True, pa=True)[0] obj = cmds.listRelatives(shape, p=True, type='transform', pa=True)[0] piv = cmds.xform(obj, q=True, ws=True, rp=True) elif pivot == 'user': piv = userPivot else: raise Exception('Invalid pivot option - "' + pivot + '"! Specify "object", "center" or "user"!!') # Scale Components if worldSpace: for component in componentList: pnt = cmds.pointPosition(component) offset = (pnt[0] - piv[0], pnt[1] - piv[1], pnt[2] - piv[2]) pnt = (piv[0] + offset[0] * scale[0], piv[1] + offset[1] * scale[1], piv[2] + offset[2] * scale[2]) cmds.move(pnt[0], pnt[1], pnt[2], component, a=True, ws=True) else: cmds.scale(scale[0], scale[1], scale[2], componentList, p=piv)
def createStalk(self): ''' This method creates the stalk. ''' # y ax is calculated by flower position mc.polyPipe(subdivisionsHeight=3) mc.scale(0.24, self.flowerTY + 1, 0.24) mc.move(0, -self.flowerTY / 2, 0) mc.displaySmoothness(divisionsU=3, divisionsV=3, pointsWire=16, pointsShaded=4, polygonObject=3) self.currentStalk = mc.ls(sl=True) currentStalk0 = self.currentStalk[0] # bend the stalk bendStalkRandomUpX = 1.5 * (1.0 - random.random()) bendStalkRandomUpZ = 1.5 * (1.0 - random.random()) for uCV in range(40, 60): mc.select(currentStalk0 + ".vtx[" + str(uCV) + "]") mc.move(bendStalkRandomUpX, 0, bendStalkRandomUpZ, r=True) mc.select(currentStalk0 + ".vtx[" + str(uCV + 60) + "]") mc.move(bendStalkRandomUpX, 0, bendStalkRandomUpZ, r=True) bendStalkRandomDownX = 1.2 * (1.0 - random.random()) bendStalkRandomDownZ = 1.2 * (1.0 - random.random()) for uCV in range(20, 40): mc.select(currentStalk0 + ".vtx[" + str(uCV) + "]") mc.move(bendStalkRandomDownX, 0, bendStalkRandomDownZ, r=True) mc.select(currentStalk0 + ".vtx[" + str(uCV + 100) + "]") mc.move(bendStalkRandomDownX, 0, bendStalkRandomDownZ, r=True) # delete history mc.select(currentStalk0) maya.mel.eval("DeleteHistory") mc.select(clear=True) return self.currentStalk
def scatter(self, scale, rotate): random.seed(1234) scaleX = random.uniform(scale[0], scale[1]) scaleY = random.uniform(scale[2], scale[3]) scaleZ = random.uniform(scale[4], scale[5]) rotateX = random.uniform(rotate[0], rotate[1]) rotateY = random.uniform(rotate[2], rotate[3]) rotateZ = random.uniform(rotate[4], rotate[5]) if cmds.objectType(self.sourceObject, isType="transform"): for vertex in self.destSel: newInstance = cmds.instance(self.sourceObject) position = cmds.pointPosition(vertex, w=True) cmds.move(position[0], position[1], position[2], newInstance, a=True, ws=True) cmds.scale(scaleX, scaleY, scaleZ, newInstance) cmds.rotate(rotateX, rotateY, rotateZ, newInstance)
def scaleShape(ctrl, scale=[1, 1, 1], index=0): ''' Rotate control shape :param ctrl: Animation control :type ctrl: str :param scale: Scale vector :type scale: list :param index: Shape index :type index: int ''' # Get control shape shape = getShape(ctrl, index) # Scale shape mc.scale(scale[0], scale[1], scale[2], rigrepo.libs.curve.getCVs(shape), relative=True)
def create_CON_separate_CT_noConnect(): sepaCON_selPLY_CT = cmds.ls(selection=True) for e in sepaCON_selPLY_CT: # Bounding Box : centerPivot sepaCON_bbInfo_CT = cmds.xform(e, worldSpace=True, query=True, boundingBox=True) sepaCON_bbCT_X_CT = (sepaCON_bbInfo_CT[0] + sepaCON_bbInfo_CT[3]) / 2.0 sepaCON_bbCT_Y_CT = (sepaCON_bbInfo_CT[1] + sepaCON_bbInfo_CT[4]) / 2.0 sepaCON_bbCT_Z_CT = (sepaCON_bbInfo_CT[2] + sepaCON_bbInfo_CT[5]) / 2.0 # Bounding Box : Size sepaCON_bbsX_CT = cmds.getAttr("%s.boundingBoxSizeX" % e) / 1.5 sepaCON_bbsY_CT = cmds.getAttr("%s.boundingBoxSizeY" % e) / 1.5 sepaCON_bbsZ_CT = cmds.getAttr("%s.boundingBoxSizeZ" % e) / 1.5 # CON sepaCON_CT = cmds.curve(degree=1, p=[(-1, 1, -1), (1, 1, -1), (1, 1, 1), (-1, 1, 1), (-1, -1, 1), (-1, -1, -1), (-1, 1, -1), (-1, 1, 1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (1, 1, -1), (1, -1, -1), (1, -1, 1), (1, -1, -1), (-1, -1, -1)]) sepaCON_rename_CT = cmds.rename(e.replace('PLY', 'CON')) CL.con_overrideColor_SET() sepaCON_NUL_CT = cmds.group(em=True, n=e.replace('PLY', 'NUL')) cmds.parent(sepaCON_rename_CT, sepaCON_NUL_CT) cmds.scale(sepaCON_bbsX_CT, sepaCON_bbsY_CT, sepaCON_bbsZ_CT, sepaCON_NUL_CT) cmds.move(sepaCON_bbCT_X_CT, sepaCON_bbCT_Y_CT, sepaCON_bbCT_Z_CT, sepaCON_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % sepaCON_NUL_CT, "%s.rotatePivot" % sepaCON_NUL_CT) cmds.move(0, 0, 0, "%s.scalePivot" % sepaCON_rename_CT, "%s.rotatePivot" % sepaCON_rename_CT) cmds.makeIdentity(sepaCON_NUL_CT, apply=1) cmds.parent(sepaCON_NUL_CT, 'control_GRP') con_ChannelBox() cmds.select(deselect=True)
def ctrl_sphere(name='ctrl_sphere', sz=1., color=21): ctrl = cmds.createNode('transform', n='%s_#' % name) ctrl_sh = cmds.createNode('nurbsCurve', n='%sShape' % ctrl, p=ctrl) cmds.setAttr('%s.v' % ctrl_sh, k=False) cmds.setAttr('%s.ove' % ctrl_sh, 1) cmds.setAttr('%s.ovc' % ctrl_sh, color) mel.eval('''setAttr ".cc" -type "nurbsCurve" 3 55 0 no 3 60 0.05 0.05 0.05 0.06 0.08 0.10 0.11 0.13 0.15 0.16 0.18 0.19 0.21 0.23 0.24 0.26 0.27 0.29 0.31 0.32 0.34 0.35 0.37 0.39 0.40 0.42 0.44 0.45 0.47 0.48 0.50 0.52 0.53 0.55 0.56 0.58 0.60 0.61 0.63 0.65 0.66 0.68 0.69 0.71 0.73 0.74 0.76 0.77 0.79 0.81 0.82 0.84 0.85 0.87 0.89 0.90 0.92 0.94 0.94 0.94 58 0.00 -0.14 0.00 0.01 -0.12 0.06 -0.07 -0.12 0.06 -0.03 -0.14 -0.08 0.11 -0.11 -0.04 0.07 -0.11 0.12 -0.11 -0.10 0.09 -0.11 -0.12 -0.10 0.07 -0.11 -0.12 0.14 -0.09 0.03 0.04 -0.10 0.14 -0.12 -0.07 0.09 -0.14 -0.07 -0.04 -0.02 -0.10 -0.14 0.12 -0.07 -0.09 0.14 -0.06 0.06 0.03 -0.05 0.15 -0.11 -0.06 0.11 -0.15 -0.01 -0.02 -0.07 -0.07 -0.14 0.08 -0.05 -0.12 0.16 -0.04 -0.02 0.11 -0.02 0.12 -0.03 -0.03 0.16 -0.14 0.01 0.07 -0.15 -0.02 -0.07 -0.03 -0.02 -0.16 0.10 -0.01 -0.13 0.16 0.02 0.00 0.10 0.01 0.13 -0.04 0.03 0.15 -0.15 0.02 0.06 -0.14 0.02 -0.09 -0.02 0.02 -0.16 0.12 0.03 -0.11 0.16 0.04 0.03 0.07 0.06 0.14 -0.08 0.05 0.13 -0.16 0.05 0.01 -0.10 0.05 -0.13 0.05 0.05 -0.15 0.15 0.07 -0.04 0.11 0.08 0.10 -0.04 0.08 0.14 -0.14 0.08 0.03 -0.10 0.08 -0.11 0.06 0.08 -0.13 0.14 0.10 -0.01 0.04 0.11 0.12 -0.10 0.10 0.08 -0.11 0.10 -0.09 0.06 0.11 -0.11 0.11 0.12 0.04 -0.03 0.12 0.12 -0.10 0.13 -0.05 0.06 0.13 -0.11 0.08 0.13 0.01 0.00 0.15 0.00;''') cmds.scale(sz, sz, sz, ctrl) #cmds.rotate(90,0,0,ctrl) cmds.makeIdentity(ctrl, apply=True, r=1, s=1) return ctrl
def ctrl_sphere2(name='ctrl_sphere2',sz=1.,color=21): ctrl=cmds.createNode('transform', n='%s_#' %name) ctrl_sh=cmds.createNode('nurbsCurve', n='%sShape' %ctrl,p=ctrl) cmds.setAttr('%s.v' %ctrl_sh,k=False) cmds.setAttr('%s.ove' %ctrl_sh,1) cmds.setAttr('%s.ovc' %ctrl_sh,color) mel.eval('''setAttr ".cc" -type "nurbsCurve" 1 53 0 no 3 54 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 0.00 0.81 0.00 -0.31 0.75 0.00 -0.57 0.57 0.00 -0.75 0.31 0.00 -0.81 0.00 0.00 -0.75 -0.31 0.00 -0.57 -0.57 0.00 -0.31 -0.75 0.00 0.00 -0.81 0.00 0.31 -0.75 0.00 0.57 -0.57 0.00 0.75 -0.31 0.00 0.81 0.00 0.00 0.75 0.31 0.00 0.57 0.57 0.00 0.31 0.75 0.00 0.00 0.81 0.00 0.00 0.75 0.31 0.00 0.57 0.57 0.00 0.31 0.75 0.00 0.00 0.81 0.00 -0.31 0.75 0.00 -0.57 0.57 0.00 -0.75 0.31 0.00 -0.81 0.00 0.00 -0.75 -0.31 0.00 -0.57 -0.57 0.00 -0.31 -0.75 0.00 0.00 -0.81 0.00 0.31 -0.75 0.00 0.57 -0.57 0.00 0.75 -0.31 0.00 0.81 0.00 -0.31 0.75 0.00 -0.57 0.57 0.00 -0.75 0.31 0.00 -0.81 0.00 0.00 -0.75 0.00 0.31 -0.57 0.00 0.57 -0.31 0.00 0.75 0.00 0.00 0.81 0.31 0.00 0.75 0.57 0.00 0.57 0.75 0.00 0.31 0.81 0.00 0.00 0.75 0.00 -0.31 0.57 0.00 -0.57 0.31 0.00 -0.75 0.00 0.00 -0.81 -0.31 0.00 -0.75 -0.57 0.00 -0.57 -0.75 0.00 -0.31 -0.81 0.00 0.00 -0.81 0.00 0.00;''') cmds.scale(sz,sz,sz,ctrl) cmds.makeIdentity(ctrl,apply=True,r=1,s=1) return ctrl
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 primaryF(height,width): base3=cmds.polyCylinder(h=.5,r=0.1,sx=6,sy=1,sz=1,name='ebase') cmds.move(0.2,0,height*0.48) cmds.rotate( '90deg', 0, 0, 'ebase' ) wing3=cmds.polyPlane(w=width,h=height, sx=2, sy=5, name='ewing') cmds.rotate(0,0,'0','ewing') cmds.select('ewing.vtx[0:2]','ewing.vtx[15:17]') cmds.move(0.172,0,0,r=True) cmds.scale(0.514005,1,1,r=True,p=[0,0.107375,2.32372]) cmds.select('ewing.vtx[0:14]') cmds.move(0.105,0,0,r=True) cmds.select('ewing.vtx[4]','ewing.vtx[7]','ewing.vtx[10]','ewing.vtx[13]') cmds.move(-0.23,0.214,0,r=True) cmds.select('ewing.vtx[0:5]') cmds.move(0.138,0,0,r=True) cmds.select('ewing.vtx[9:17]') cmds.move(-0.052,0,0,r=True) cmds.select('ewing.vtx[0:8]') cmds.move(-0.037,0,0,r=True) cmds.select('ewing.vtx[5]','ewing.vtx[8]','ewing.vtx[11]','ewing.vtx[14]') cmds.move(-0.156,0,0,r=True) cmds.select('ewing.vtx[0]','ewing.vtx[2]') cmds.move(-0.065,0,-0.33,r=True) cmds.select('ewing.vtx[1]') cmds.move(0,0,-0.356,r=True) primW=cmds.polyUnite( 'ebase', 'ewing', n='primaryF' ) cmds.select('primaryF.vtx[30]') cmds.move(0,0,-1.1 ,r=True) cmds.select('primaryF.vtx[31]') cmds.move(-0.405016,0,0 ,r=True) cmds.move(-(width*10), 0 ,0, 'primaryF') cmds.rotate('180deg',0,0,'primaryF') colorW('primaryF',0.493,0.183396,0.183396) checkAndDel('primaryF');