def b052(self): #transfer crease edges ''' an updated version of this is in the maya python projects folder the use of separate buttons for donar and target mesh are obsolete add pm.polySoftEdge (angle=0, constructionHistory=0); #harden edge, when applying crease ''' creaseSet = str(self.ui.b042.text()) newObject = str(self.ui.b043.text()) sets = pm.sets(creaseSet, query=1) setArray = [] for set_ in sets: name = str(set_) setArray.append(name) print setArray pm.undoInfo(openChunk=1) for set_ in setArray: oldObject = ''.join(set_.partition( '.')[:1]) #ex. pSphereShape1 from pSphereShape1.e[260:299] pm.select(set_, replace=1) value = pm.polyCrease(query=1, value=1)[0] name = set_.replace(oldObject, newObject) pm.select(name, replace=1) pm.polyCrease(value=value, vertexValue=value, createHistory=True) # print "crease:", name pm.undoInfo(closeChunk=1) func.setButtons(self.ui, disable='b052', unchecked='b042') #,self.ui.b043]) self.ui.b042.setText("Crease Set")
def b009(self): #Subdiv proxy global polySmoothBaseMesh polySmoothBaseMesh = [] #disable creating seperate layers for subdiv proxy pm.optionVar(intValue=["polySmoothLoInLayer", 0]) pm.optionVar(intValue=["polySmoothHiInLayer", 0]) #query smooth proxy state. sel = mel.eval("polyCheckSelection \"polySmoothProxy\" \"o\" 0") if len(sel) == 0 and len(polySmoothBaseMesh) == 0: print "// Warning: Nothing selected." return if len(sel) != 0: del polySmoothBaseMesh[:] for object_ in sel: polySmoothBaseMesh.append(object_) elif len(polySmoothBaseMesh) != 0: sel = polySmoothBaseMesh transform = pm.listRelatives(sel[0], fullPath=1, parent=1) shape = pm.listRelatives(transform[0], pa=1, shapes=1) #check shape for an existing output to a smoothProxy attachedSmoothProxies = pm.listConnections(shape[0], type="polySmoothProxy", s=0, d=1) if len(attachedSmoothProxies) == 0: #subdiv on func.setButtons(self.ui, enable='b000', checked='b009') else: func.setButtons(self.ui, disable='b000', unchecked='b009') mel.eval("smoothingDisplayToggle 0;") #toggle performSmoothProxy mel.eval("performSmoothProxy 0;") #toggle SubDiv Proxy;
def chk003(self): #Crease: Max if self.ui.chk003.isChecked(): self.ui.s003.setValue(10) #crease value self.ui.s004.setValue(30) #normal angle func.setButtons(self.ui, unchecked='chk002') else: self.ui.s003.setValue(7.5) #crease value self.ui.s004.setValue(60) #normal angle
def chk002(self): #Un-crease if self.ui.chk002.isChecked(): self.ui.s003.setValue(0) #crease value self.ui.s004.setValue(180) #normal angle func.setButtons(self.ui, unchecked='chk003') else: self.ui.s003.setValue(7.5) #crease value self.ui.s004.setValue(30) #normal angle
def chk006(self): #Symmetry: topo self.ui.chk005.setChecked(False) #uncheck symmetry:object space if any([ self.ui.chk000.isChecked(), self.ui.chk001.isChecked(), self.ui.chk002.isChecked() ]): #(symmetry) pm.symmetricModelling(edit=True, symmetry=False) func.setButtons(self.ui, unchecked='chk000,chk001,chk002') print "# Warning: First select a seam edge and then check the symmetry button to enable topographic symmetry #"
def chk007(self): #delete: translate to components if self.ui.chk007.isChecked(): func.setButtons(self.ui, enable='chk008,b034,cmb000', disable='chk000,chk009,s005') self.b034() else: func.setButtons(self.ui, disable='chk008,b034,cmb000', enable='chk000,chk009,s005')
def chk002(self): #rotate z axis func.setButtons(self.ui, checked='chk002', unchecked='chk001,chk000') obj = pm.ls(sl=1)[0] if obj: axis = self.rotation['z'] rotateOrder = pm.xform(obj, query=1, rotateOrder=1) pm.xform(obj, preserve=1, rotation=axis, rotateOrder=rotateOrder, absolute=1) self.rotation['last'] = axis else: print "# Warning: nothing selected #"
def b043(self): #hold transform node name for crease set transfer if self.ui.b043.isChecked(): newObject = str( pm.ls(selection=1)) #ex. [nt.Transform(u'pSphere1')] index1 = newObject.find("u") index2 = newObject.find(")") newObject = newObject[index1 + 1:index2].strip("'") #ex. pSphere1 if newObject != "[": self.ui.b043.setText(newObject) else: self.ui.b043.setText("must select obj first") func.setButtons(self.ui, unchecked='b043') if self.ui.b042.isChecked(): func.setButtons(self.ui, enable='b052') else: self.ui.b043.setText("Object")
def b042(self): #hold crease set name for crease set transfer if self.ui.b042.isChecked(): creaseSet = str( pm.ls(selection=1)) #ex. [nt.CreaseSet(u'creaseSet1')] index1 = creaseSet.find("u") index2 = creaseSet.find(")") creaseSet = creaseSet[index1 + 1:index2].strip( "'") #ex. creaseSet1 if creaseSet != "[": self.ui.b042.setText(creaseSet) else: self.ui.b042.setText("must select set first") func.setButtons(self.ui, unchecked='b042') if self.ui.b043.isChecked(): func.setButtons(self.ui, enable='b052') else: self.ui.b042.setText("Crease Set")
def chk010(self): #Radial Array: set pivot global radialPivot radialPivot = [] #add support for averaging multiple components. if self.ui.chk010.isChecked(): selection = pm.ls(selection=1, flatten=1) try: pivot = pm.xform(selection, query=1, translation=1, relative=1) except: print "# Warning: Nothing selected. #" func.setButtons(self.ui, unchecked='chk010') return # radialPivot.extend ([pivot[0],pivot[1],pivot[2]]) radialPivot.extend(pivot) #extend the list contents text = str(int(pivot[0])) + "," + str(int(pivot[1])) + "," + str( int(pivot[2])) #convert to int to self.ui.chk010.setText(text) else: del radialPivot[:] self.ui.chk010.setText("Set Pivot")
def chk005(self): #Create: set point #add support for averaging multiple components. selection = pm.ls(selection=1, flatten=1) try: point = pm.xform(selection, query=1, translation=1, worldSpace=1, absolute=1) self.ui.s009.setValue(point[0]) self.ui.s010.setValue(point[1]) self.ui.s011.setValue(point[2]) self.point = point #extend the list contents func.setButtons(self.ui, visible='s009,s010,s011') except: print "# Warning: Nothing selected. #" self.ui.s009.setValue(0) self.ui.s010.setValue(0) self.ui.s011.setValue(0) if self.point: del self.point[:]
def chk005(self): #transform: scale func.setButtons(self.ui, unchecked='chk008,chk009', checked='chk000,chk001,chk002') self.ui.s000.setValue(2) self.ui.s000.setSingleStep(1)
def chk009(self): #transform: rotate func.setButtons(self.ui, unchecked='chk005,chk008,chk000,chk001,chk002') self.ui.s000.setValue(45) self.ui.s000.setSingleStep(5)
def chk008(self): #transform: move func.setButtons(self.ui, unchecked='chk005,chk009,chk000,chk001,chk002') self.ui.s000.setValue(0.1) self.ui.s000.setSingleStep(0.1)
def chk003(self): #delete: y axis func.setButtons(self.ui, unchecked='chk002,chk004') axis = "Y" if self.ui.chk001.isChecked(): axis = "-Y" self.ui.b000.setText("Mirror " + axis)
def chk004(self): #delete: z axis func.setButtons(self.ui, unchecked='chk003,chk002') axis = "Z" if self.ui.chk001.isChecked(): axis = "-Z" self.ui.b000.setText("Mirror " + axis)
def chk001(self): #Symmetry Y func.setButtons(self.ui, unchecked='chk000,chk002') state = self.ui.chk001.isChecked() #symmetry button state self.setSymmetry("y", symmetry=state)
def chk015(self, create=False): #Duplicate radial array. global radialArrayObjList radialArrayObjList = [] setPivot = self.ui.chk010.isChecked() #set pivot point instance = self.ui.chk011.isChecked() #instance object if self.ui.chk015.isChecked(): func.setButtons(self.ui, enable='b008') selection = pm.ls(selection=1, type="transform", flatten=1) if len(selection): objectName = str(selection[0]) if len(radialArrayObjList): func.try_('pm.delete (radialArrayObjList)') del radialArrayObjList[:] numDuplicates = int(self.ui.s000.value()) angle = float(self.ui.s001.value()) x = y = z = 0 if self.ui.chk012.isChecked(): x = angle if self.ui.chk013.isChecked(): y = angle if self.ui.chk014.isChecked(): z = angle pm.undoInfo(openChunk=1) for i in xrange(1, numDuplicates): if instance: name = objectName + "_ins" + str(i) pm.instance(name=name) else: name = objectName + "_dup" + str(i) pm.duplicate(returnRootsOnly=1, name=name) if setPivot: if len(radialPivot): pm.rotate(x, y, z, relative=1, pivot=radialPivot) else: print "# Warning: No pivot point set. #" else: pm.rotate(x, y, z, relative=1) radialArrayObjList.append(name) #if in isolate select mode; add object currentPanel = pm.paneLayout( 'viewPanes', q=True, pane1=True) #get the current modelPanel view if pm.isolateSelect(currentPanel, query=1, state=1): for obj in radialArrayObjList: pm.isolateSelect(currentPanel, addDagObject=obj) #re-select the original selected object pm.select(objectName) pm.undoInfo(closeChunk=1) else: #if both lists objects are empty: print "# Warning: Nothing selected. #" func.setButtons(self.ui, disable='b008', unchecked='chk015') return else: #if chk015 is unchecked by user or by create button if create: originalObj = radialArrayObjList[0][:radialArrayObjList[0].rfind( "_" )] #remove the trailing _ins# or _dup#. ie. pCube1 from pCube1_inst1 radialArrayObjList.append(originalObj) pm.polyUnite( radialArrayObjList, name=originalObj + "_array" ) #combine objects. using the original name results in a duplicate object error on deletion print "# Result: " + str(radialArrayObjList) + " #" pm.delete(radialArrayObjList) del radialArrayObjList[:] return func.try_('pm.delete (radialArrayObjList)') del radialArrayObjList[:] func.setButtons(self.ui, disable='b008')
def cmb001(self): #set create object if self.ui.chk000.isChecked(): axis = self.rotation['x'] if self.ui.chk001.isChecked(): axis = self.rotation['y'] if self.ui.chk002.isChecked(): axis = self.rotation['z'] self.rotation['last'] = axis if self.ui.cmb001.currentIndex() == 0: func.setButtons(self.ui, disable='b000,chk003,chk004', invisible='t000') return else: func.setButtons(self.ui, enable='b000', visible='s009,s010,s011,t000') #nurbs if self.ui.cmb000.currentIndex() == 1: #Sphere if self.ui.cmb001.currentIndex() == 1: v = func.setSpinboxes(self.ui, values=[("radius", 5), ("start sweep", 0), ("end sweep", 360), ("sections", 8), ("spans", 1), ("height ratio", 2)]) node = pm.sphere(esw=360, ch=1, d=3, ut=0, ssw=0, p=(0, 0, 0), s=8, r=1, tol=0.01, nsp=4, ax=(0, 1, 0)) #Cube if self.ui.cmb001.currentIndex() == 2: v = func.setSpinboxes(self.ui, values=[("width", 1), ("length ratio", 1), ("height ratio", 1), ("patches U", 1), ("patches V", 1)]) node = pm.nurbsCube(ch=1, d=3, hr=1, p=(0, 0, 0), lr=1, w=1, v=1, ax=(0, 1, 0), u=1) #Cylinder if self.ui.cmb001.currentIndex() == 3: v = func.setSpinboxes(self.ui, values=[("radius", 5), ("start sweep", 0), ("end sweep", 360), ("sections", 8), ("spans", 1), ("height ratio", 2)]) node = pm.cylinder(esw=360, ch=1, d=3, hr=2, ut=0, ssw=0, p=(0, 0, 0), s=8, r=1, tol=0.01, nsp=1, ax=(0, 1, 0)) #Cone if self.ui.cmb001.currentIndex() == 4: v = func.setSpinboxes(self.ui, values=[("radius", 5), ("start sweep", 0), ("end sweep", 360), ("sections", 8), ("spans", 1), ("height ratio", 2)]) node = pm.cone(esw=360, ch=1, d=3, hr=2, ut=0, ssw=0, p=(0, 0, 0), s=8, r=1, tol=0.01, nsp=1, ax=(0, 1, 0)) #Plane if self.ui.cmb001.currentIndex() == 5: v = func.setSpinboxes(self.ui, values=[("width", 1), ("length ratio", 1), ("patches U", 1), ("patches V", 1)]) node = pm.nurbsPlane(ch=1, d=3, v=1, p=(0, 0, 0), u=1, w=1, ax=(0, 1, 0), lr=1) #Torus if self.ui.cmb001.currentIndex() == 6: v = func.setSpinboxes(self.ui, values=[("radius", 5), ("start sweep", 0), ("end sweep", 360), ("sections", 8), ("spans", 4), ("height ratio", 1), ("minor sweep", 360)]) node = pm.torus(esw=360, ch=1, d=3, msw=360, ut=0, ssw=0, hr=0.5, p=(0, 0, 0), s=8, r=1, tol=0.01, nsp=4, ax=(0, 1, 0)) #Circle if self.ui.cmb001.currentIndex() == 7: v = func.setSpinboxes(self.ui, values=[("normal X", 0), ("normal Y", 1), ("normal Z", 0), ("center X", 0), ("center Y", 0), ("center Z", 0), ("radius", 1), ("sections", 8)]) node = pm.circle(c=(0, 0, 0), ch=1, d=3, ut=0, sw=360, s=8, r=1, tol=0.01, nr=(0, 1, 0)) #Square if self.ui.cmb001.currentIndex() == 8: v = func.setSpinboxes(self.ui, values=[("normal X", 0), ("normal Y", 1), ("normal Z", 0), ("center X", 0), ("center Y", 0), ("center Z", 0), ("side length 1", 1), ("side length 2", 1), ("spans per side", 1)]) node = pm.nurbsSquare(c=(0, 0, 0), ch=1, d=3, sps=1, sl1=1, sl2=1, nr=(0, 1, 0)) #lights if self.ui.cmb000.currentIndex() == 2: pass #polygons if self.ui.cmb000.currentIndex() == 0: #cube: if self.ui.cmb001.currentIndex() == 1: v = func.setSpinboxes(self.ui, values=[("size", 15), ("width", 5), ("depth", 5), ("height", 5), ("divisions X", 1), ("divisions Y", 1), ("divisions Z", 1)]) node = pm.polyCube(axis=axis, width=v[1], height=v[2], depth=v[3], subdivisionsX=v[4], subdivisionsY=v[5], subdivisionsZ=v[6]) #sphere: if self.ui.cmb001.currentIndex() == 2: v = func.setSpinboxes(self.ui, values=[("size", 5), ("divisions X", 1), ("divisions Y", 1)]) node = pm.polySphere(axis=axis, radius=v[0], subdivisionsX=v[1], subdivisionsY=v[2]) #cylinder: if self.ui.cmb001.currentIndex() == 3: v = func.setSpinboxes(self.ui, values=[("size", 15), ("radius", 5), ("height", 10), ("sides", 5), ("divisions height", 1), ("divisions caps", 1), ("round cap", 0)]) node = pm.polyCylinder(axis=axis, radius=v[1], height=(v[2]), subdivisionsX=v[3], subdivisionsY=v[4], subdivisionsZ=v[5]) #plane: if self.ui.cmb001.currentIndex() == 4: v = func.setSpinboxes(self.ui, values=[("size", 10), ("width", 5), ("height", 5), ("divisions X", 1), ("divisions Y", 1)]) node = pm.polyPlane(axis=axis, width=v[1], height=v[2], subdivisionsX=v[3], subdivisionsY=v[4]) #circle: if self.ui.cmb001.currentIndex() == 5: mode = None if self.ui.chk003.isChecked(): mode = "tri" if self.ui.chk004.isChecked(): mode = "quad" axis = next( key for key, value in self.rotation.items() if value == axis and key != 'last' ) #get key from value as createCircle takes the key argument func.setButtons(self.ui, enable='chk003,chk004') v = func.setSpinboxes(self.ui, values=[("size", 5), ("sides", 5)]) node = func.createCircle(axis=axis, numPoints=v[0], radius=v[1], mode=mode) #Cone: if self.ui.cmb001.currentIndex() == 6: v = func.setSpinboxes(self.ui, values=[("size", 10), ("radius", 5), ("height", 5), ("divisions X", 1), ("divisions Y", 1), ("divisions Z", 1), ("round cap", 0)]) node = pm.polyCone(axis=axis, radius=v[1], height=v[2], subdivisionsX=v[3], subdivisionsY=v[4], subdivisionsZ=v[5]) #Pyramid if self.ui.cmb001.currentIndex() == 7: v = func.setSpinboxes(self.ui, values=[("size", 10), ("side length", 5), ("sides", 3), ("divisions height", 1), ("divisions caps", 1)]) node = pm.polyPyramid(axis=axis, sideLength=5, numberOfSides=5, subdivisionsHeight=1, subdivisionsCaps=1) #Torus: if self.ui.cmb001.currentIndex() == 8: v = func.setSpinboxes(self.ui, values=[("size", 20), ("radius", 10), ("section radius", 5), ("twist", 0), ("divisions X", 5), ("divisions Y", 5)]) node = pm.polyTorus(axis=axis, radius=v[1], sectionRadius=v[2], twist=v[3], subdivisionsX=v[4], subdivisionsY=v[5]) #Pipe if self.ui.cmb001.currentIndex() == 9: v = func.setSpinboxes(self.ui, values=[("size", 10), ("radius", 5), ("thickness", 5), ("divisions height", 1), ("divisions caps", 1)]) node = pm.polyPipe(axis=axis, radius=v[1], height=v[2], thickness=v[3], subdivisionsHeight=v[4], subdivisionsCaps=v[5]) #Soccer ball if self.ui.cmb001.currentIndex() == 10: v = func.setSpinboxes(self.ui, values=[("size", 10), ("radius", 5), ("side length", 5)]) node = pm.polyPrimitive(axis=axis, radius=v[1], sideLength=v[2], polyType=0) #Platonic solids if self.ui.cmb001.currentIndex() == 11: mel.eval("performPolyPrimitive PlatonicSolid 0;") #translate the newly created node pm.xform(node, translation=self.point, worldSpace=1, absolute=1) #show text field and set name self.ui.t000.setText(str(node[0])) #set as current node for setting history self.history.extend(node) print self.history[0], self.history[1]
def chk012(self): #Radial array: x axis func.setButtons(self.ui, checked='chk012', unchecked='chk013,chk014') self.chk015()
def chk009(self): #Split V func.setButtons(self.ui, unchecked='chk010')
def b004(self): #Align vertices if self.ui.chk010.isChecked( ): #if checked; set coordinates for auto align: sel = pm.ls(selection=1) if len(sel) != 0: point = pm.xform(sel[0], q=True, t=True, ws=True) #vertex point 1 x1 = round(point[0], 4) y1 = round(point[1], 4) z1 = round(point[2], 4) #vertex point 2 x2 = round(point[3], 4) y2 = round(point[4], 4) z2 = round(point[5], 4) #find the axis with the largest variance to determine direction. x = abs(x1 - x2) y = abs(y1 - y2) z = abs(z1 - z2) vertex = pm.polyListComponentConversion(fromEdge=1, toVertexFace=1)[0] vertexTangent = pm.polyNormalPerVertex(vertex, query=True, xyz=True) tx = abs(round(vertexTangent[0], 4)) ty = abs(round(vertexTangent[1], 4)) tz = abs(round(vertexTangent[2], 4)) axis = max(x, y, z) tangent = max(tx, ty, tz) if self.ui.chk011.isChecked(): if axis == x: #"yz" func.setButtons(self.ui, checked='b030,b031', unchecked='b029') if axis == y: #"xz" func.setButtons(self.ui, checked='b029,b031', unchecked='b030') if axis == z: #"xy" func.setButtons(self.ui, checked='b029,b030', unchecked='b031') else: if any([ axis == x and tangent == ty, axis == y and tangent == tx ]): #"z" func.setButtons(self.ui, checked='b031', unchecked='b029,b030') if any([ axis == x and tangent == tz, axis == z and tangent == tx ]): #"y" func.setButtons(self.ui, checked='b030', unchecked='b029,b031') if any([ axis == y and tangent == tz, axis == z and tangent == ty ]): #"x" func.setButtons(self.ui, checked='b029', unchecked='b030,b031') else: print "// Warning: An edge must be selected. //" return #align x = self.ui.b029.isChecked() y = self.ui.b030.isChecked() z = self.ui.b031.isChecked() avg = self.ui.chk006.isChecked() loop = self.ui.chk007.isChecked() if all([x, not y, not z]): #align x func.alignVertices(mode=3, average=avg, edgeloop=loop) if all([not x, y, not z]): #align y func.alignVertices(mode=4, average=avg, edgeloop=loop) if all([not x, not y, z]): #align z func.alignVertices(mode=5, average=avg, edgeloop=loop) if all([not x, y, z]): #align yz func.alignVertices(mode=0, average=avg, edgeloop=loop) if all([x, not y, z]): #align xz func.alignVertices(mode=1, average=avg, edgeloop=loop) if all([x, y, not z]): #align xy func.alignVertices(mode=2, average=avg, edgeloop=loop) if all([x, y, z]): #align xyz func.alignVertices(mode=6, average=avg, edgeloop=loop)
def chk010(self): #align: auto align if self.ui.chk010.isChecked(): func.setButtons(self.ui, disable='b029,b030,b031') else: func.setButtons(self.ui, enable='b029,b030,b031')
def chk004(self): #division level 5 func.setAttributesOnSelected(attribute=".smoothLevel", value=5) pm.optionVar(intValue=["proxyDivisions", 5]) #subDiv proxy options: 'divisions' func.setButtons(self.ui, unchecked='chk000,chk001,chk002,chk003')
def chk002(self): #Symmetry Z func.setButtons(self.ui, unchecked='chk000,chk001') state = self.ui.chk002.isChecked() #symmetry button state self.setSymmetry("z", symmetry=state)
def chk009(self): #tessellation level 10 func.setAttributesOnSelected(attribute=".smoothTessLevel", value=10) func.setButtons(self.ui, unchecked='chk005,chk006,chk007,chk008')
def chk014(self): #Radial array: z axis func.setButtons(self.ui, checked='chk014', unchecked='chk012,chk013') self.chk015()
def chk010(self): #tris func.setButtons(self.ui, unchecked='chk008,chk009')
def chk000(self): #Symmetry X func.setButtons(self.ui, unchecked='chk001,chk002') state = self.ui.chk000.isChecked() #symmetry button state self.setSymmetry("x", symmetry=state)