def dup(*args): neg = cmds.checkBox("negChck", q=True, v=True) mrge = cmds.checkBox("mrgChck", q=True, v=True) dupAx = cmds.radioButtonGrp("axChck", q=True, sl=True) selected = cmds.ls(sl=True) print(mrge) if(dupAx==1): scaD = ".scaleX" if(dupAx==2): scaD = ".scaleY" if(dupAx==3): scaD = ".scaleZ" if(neg==1): scaVal = -1 else: scaVal = 1 newDup = cmds.duplicate(rr=True) cmds.setAttr(newDup[0] + scaD, scaVal) if (mrge==1): cmds.polyUnite(selected, newDup[0]) cmds.polyMergeVertex(d=1) else: None
def vertexAnimTimeline(*args): selection = cmds.ls(sl=True) if len(selection) == 0: om.MGlobal.displayError("Please Select Something") return combinedName = selection[0] + "combined" if len(selection) > 1: cmds.polyUnite(selection, n=combinedName) selection = combinedName gStepSize = updateStepSize() print "STEPSIZE: " + str(gStepSize) startFrame = cmds.playbackOptions(q=True, minTime=True) endFrame = cmds.playbackOptions(q=True, maxTime=True) frameList = range(int(startFrame), int(endFrame) + 1) frameList = frameList[0::gStepSize] selectionList = [] for frame in frameList: cmds.select(selection) newName = "frame" + str(frame) cmds.currentTime(frame, edit=True) cmds.duplicate(name=newName) selectionList.append(newName) #print selectionList cmds.delete(selection) main(selectionList)
def repartirRochers(nb, rotation, scale_min, scale_max, colo=[177, 81, 81]): if cmds.objExists("Rocher*"): cmds.delete("Rocher*") #-----import des rochers setImport('Rocher_enorme.fbx') setImport('Rocher_gros.fbx') setImport('Rocher_moyen.fbx') setImport('Rocher_petit.fbx') nbP = nb / 2 nbM = nb / 2 nbG = 2 nbE = 1 #----- appel de la fonction de repartition Repartition('Rocher_enorme', 'fond', nbE, rotation, scale_min, scale_max) Repartition('Rocher_gros', 'fond', nbG, rotation, scale_min, scale_max) Repartition('Rocher_moyen', 'fond', nbM, rotation, scale_min, scale_max) Repartition('Rocher_petit', 'fond', nbP, rotation, scale_min, scale_max) cmds.select("Rocher*") listeRock = cmds.ls(sl=True, fl=True) cmds.polyUnite(listeRock, n="Rochers") #_______ application couleurs ________# ApplyColor("Rocher", colo, 0)
def main(array,flag1,flag2): if flag2 == 'None': c1 = creatCurve(array[0],array[1]) c2 = creatCurve(array[-1],array[-2]) elif flag2 == '1': c1 = creatCurve(array[0],array[-2]) c2 = creatCurve(array[1],array[-1]) else: c1 = creatCurve(array[0],array[-1]) c2 = creatCurve(array[1],array[-2]) cmds.loft( c1, c2, ch=True, rn=True, ar=True, po = True ) cmds.delete(c1,c2) if flag1: obj0 = array[0].split('.')[0] obj1 = cmds.ls(sl = True, fl = True)[0] cmds.polyUnite(obj0,obj1) obj2 = cmds.ls(sl = True, fl = True)[0] array1 = [] for a in array: a = obj2 + '.' + a.split('.')[1] array1.append(a) cmds.select(cmds.polyListComponentConversion(obj2, tv = True)) n0 = cmds.ls(sl = True, fl = True) if len(array) == 4: cmds.select(n0[-4:]) else: cmds.select(n0[-3:]) cmds.select(array1,add = True) cmds.polyMergeVertex(d = 0.001) cmds.select(obj2)
def main(selection, *args): print "COMPUTING FRAMES..." id = 0 for item in selection: #Progress bar cmds.separator(height=10, style="none") cmds.separator(height=10, style="none") cmds.text(label="") progressControl = cmds.progressBar(h=25, width=385, max=len(selection)) cmds.separator(height=10, style="none") cmds.separator(height=10, style="none") cmds.progressBar(progressControl, edit=True, step=1) copyUVSet(item) modifyUVs(item, id) print str(id + 1) + "/" + str(len(selection)) + " PROCESSED" id += 1 print "COMBINGING MESHES..." cmds.select(selection) cmds.polyUnite(muv=True) cmds.progressBar(progressControl, edit=True, step=1) cmds.DeleteHistory() print "FINSIHED"
def makeStreetTree(shaders): ''' Creates a tree on a circular platform and with a circular fence around it. shaders: A list of shaders for the tree crowns. On exit: A tree has been created using makeTree(...), a circular platform has been created underneath it and a fence around it. Appropriate shaders have been assigned. Everything is united into one polygonal object and returned as a tuple with the object name and the node name. ''' tree = makeTree(shaders) platform = cmds.polyCylinder(name = "platform",h = 0.1, r = 0.8) cmds.move(0.25, y = True) cmds.sets(platform[0], edit=True, forceElement="fountainMaterialGroup") pole = cmds.polyCube(name = "pole", h = 0.6, w = 0.04, d = 0.04) cmds.xform(pole, t = (0.7,0.45,0)) angle = 360/10.0 for i in range(1,10): pole1 = cmds.polyCube(name = "pole", h = 0.6, w = 0.04, d = 0.04) cmds.rotate(angle * i, y = True) cmds.move(0.7,0.45,0, os = True) pole = cmds.polyUnite(pole, pole1) bar = cmds.polyPipe(name = "bar", h = 0.1, r = 0.65, t = 0.04) cmds.move(0.65, y = True) bar1 = cmds.duplicate(bar[0]) cmds.move(-0.2, y = True, r = True) fence = cmds.polyUnite(pole, bar, bar1) cmds.sets(fence[0], edit=True, forceElement="blackMetalGroup") streetTree = cmds.polyUnite(tree,platform, fence) cmds.delete(streetTree, ch = True) return streetTree
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 chipFacesTool(self): # cuts faces off of the poly and then seperates the faces to it's own polygon object, also ungroups them selectedFaces = self.getSelection() selectionParent = cmds.listRelatives(selectedFaces[0], p=True) cmds.polyChipOff( selectedFaces, dup=True) seperated = cmds.polySeparate(selectionParent[0]) allSeperated = [i for i in seperated if 'Separate' not in i] if len(allSeperated) > 2: cmds.polyUnite(allSeperated[1:]) new = self.getSelection() else: new = allSeperated[1] old = []; old.append(allSeperated[0]) oldParent = cmds.listRelatives(old[0], p=True) oldParentChildren = cmds.listRelatives(oldParent[0], c=True) oldNodesToDelete = set(old) ^ set(oldParentChildren) print oldNodesToDelete, ' this is old nodes to delete' cmds.ungroup( oldParent ) cmds.delete(new, ch=1) cmds.delete(old, ch=1) cmds.rename(old, oldParent ) cmds.select(new) self.assignRandomMaterial() # assigns random lambert to newly created poly cmds.delete(selectedFaces) cmds.select(old) cmds.xform(centerPivots = True) cmds.select(new) # reselect it after material assign cmds.xform(centerPivots = True) # Center pivot of new article. JR_rename_tool.UI('exit') # to rename the freshly branched poly
def merge_tree(self): segmentsList = cmds.ls('treePart*') foliageList = cmds.ls('leaves*') if len(segmentsList) < 3: treeTrunk = segmentsList[0] else: treeTrunk = cmds.polyUnite(segmentsList) newTree = cmds.duplicate(treeTrunk, name='miniTreeTrunk') cmds.polyMergeVertex(newTree) cmds.sets(newTree, e=1, forceElement=treeTrunkShaderSG) cmds.delete(treeTrunk) if len(foliageList) < 3: leaves = foliageList[0] else: leaves = cmds.polyUnite(foliageList) newLeaves = cmds.duplicate(leaves, name='miniTreeFoliage') cmds.sets(newLeaves, e=1, forceElement=foliageShaderSG) cmds.delete(leaves) segmentsList = cmds.ls('treePart*') if len(segmentsList) > 0: cmds.delete(segmentsList) foliageList = cmds.ls('leaves*') if len(foliageList) > 0: cmds.delete(foliageList)
def cleanProcedure(): cmds.undoInfo(ock=1) sel = cmds.ls(sl=1) selRelatives = cmds.listRelatives(sel) if selRelatives[0].startswith('instanceAlongCurveLocator'): selectedLocator = [] selectedLocator=cmds.ls(sl=1) tempGroupName = "" tempGroupName=str(cmds.group(em=1, n='InstanceMesh')) selectedMesh = [] selectedMeshDuplicatedShape = [] selectedThings = [] cmds.select(selectedLocator) selectedThings=cmds.listRelatives(c=1) selectedMesh=cmds.filterExpand(sm=12) cmds.select(selectedMesh) selectedMeshDuplicatedShape=cmds.listRelatives(c=1) eachOverride=selectedMeshDuplicatedShape[0] + ".overrideEnabled" cmds.setAttr(eachOverride, 1) selectedMeshDuplicated=cmds.duplicate() cmds.parent(selectedMeshDuplicated, tempGroupName) cmds.ungroup(tempGroupName) cmds.delete(selectedLocator) cmds.select(selectedMeshDuplicated) cmds.polyUnite(centerPivot=1, ch=1, mergeUVSets=1) separatedMesh = [] separatedMesh=cmds.polySeparate(ch=1) cmds.CenterPivot() separatedMeshGroup=cmds.listRelatives(separatedMesh, p=1) cmds.select(separatedMeshGroup) cmds.select(selectedMeshDuplicated, add=1) cmds.ungroup() cmds.DeleteHistory() resultAll = cmds.ls(sl=1,o=1) result = cmds.filterExpand(resultAll,sm=12) toDelete = list(set(resultAll).difference(set(result))) cmds.delete(toDelete) else: try: selectedForClean=cmds.ls(sl=1) cmds.polyCube(sz=1, sy=1, sx=1, d=1, cuv=4, h=1, ch=1, w=1, ax=(0, 1, 0)) temp_polyCube=cmds.ls(sl=1) cmds.select(selectedForClean) cmds.select(temp_polyCube, add=1) cmds.CombinePolygons() temp_BeforeSeparate=cmds.ls(sl=1) cmds.SeparatePolygon() temp_AfterSeparate=cmds.ls(sl=1) cmds.delete(temp_AfterSeparate[- 1]) cmds.DeleteHistory() temp_father=cmds.listRelatives(temp_AfterSeparate[0], p=1) cmds.select(temp_BeforeSeparate) cmds.ungroup() cmds.delete(selectedForClean) cmds.CombinePolygons() cmds.DeleteHistory() except: pass cmds.undoInfo(cck=1)
def generate(cls, *args): components = [] boolean = [] width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True) rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True) block_width = width * Constants["block_width_unit"] block_height = Constants["block_height_unit"] block_depth = Constants["block_depth_unit"] for x in range(0, width): stub = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Stub"), radius=Constants["stub_radius"], height = Constants["stub_height"]) components.append(stub[0]) cmds.move(Constants["block_width_unit"] * x + half(Constants["block_width_unit"]), half(Constants["block_height_unit"]) + half(Constants["stub_height"]), half(Constants["block_depth_unit"]), stub[0]) for x in range(0, width-1): hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2) boolean.append(hole[0]) cmds.rotate('90deg', 0, 0, hole[0]) cmds.move(Constants["block_width_unit"] * x + Constants["block_width_unit"], 0, half(Constants["block_depth_unit"]), hole[0]) cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth) components.append(cube[0]) cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube) solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), "")) boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean")) final = cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") ) shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat")) cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3') cmds.select(final[0], r=True) cmds.hyperShade(assign=shader)
def chipFacesTool(self): # cuts faces off of the poly and then seperates the faces to it's own polygon object, also ungroups them selectedFaces = self.getSelection() selectionParent = cmds.listRelatives(selectedFaces[0], p=True) cmds.polyChipOff(selectedFaces, dup=True) seperated = cmds.polySeparate(selectionParent[0]) allSeperated = [i for i in seperated if 'Separate' not in i] if len(allSeperated) > 2: cmds.polyUnite(allSeperated[1:]) new = self.getSelection() else: new = allSeperated[1] old = [] old.append(allSeperated[0]) oldParent = cmds.listRelatives(old[0], p=True) oldParentChildren = cmds.listRelatives(oldParent[0], c=True) oldNodesToDelete = set(old) ^ set(oldParentChildren) print oldNodesToDelete, ' this is old nodes to delete' cmds.ungroup(oldParent) cmds.delete(new, ch=1) cmds.delete(old, ch=1) cmds.rename(old, oldParent) cmds.select(new) self.assignRandomMaterial( ) # assigns random lambert to newly created poly cmds.delete(selectedFaces) cmds.select(old) cmds.xform(centerPivots=True) cmds.select(new) # reselect it after material assign cmds.xform(centerPivots=True) # Center pivot of new article. JR_rename_tool.UI('exit') # to rename the freshly branched poly
def CombineAndReparent(): newSelectionList = [] selectionList = Cmds.ls(sl=True) for selection in selectionList: if Cmds.nodeType(selection) in ["transform"]: children = Cmds.listRelatives(selection, children=True) Cmds.select(cl=True) for child in children: Cmds.select(selection + "|" + child, add=True) if (len(children) == 1): Cmds.parent(w=True) Cmds.delete(selection) else: Cmds.polyUnite(ch=True, name=selection) Cmds.delete(ch=True) newName = selection print newName if not newName.find("LOD") == -1: nameParts = newName.split('_', 1) newName = "%s_%s" % (nameParts[1], nameParts[0]) Cmds.rename(newName) Cmds.polyQuad(a=30, kgb=True, ktb=True, khe=True, ws=True, ch=True) newSelectionList.extend(Cmds.ls(sl=True)) for selection in newSelectionList: Cmds.select(selection, add=True) Cmds.group(name="Scene") Cmds.delete(ch=True)
def Merge(nsTmp): combine = cmds.checkBoxGrp('merge', q=True, v1=True) rgb = cmds.colorSliderGrp('chainColour', q=True, rgbValue=True) if combine == True: myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat") cmds.setAttr(nsTmp + ":blckMat.color", rgb[0], rgb[1], rgb[2], typ='double3') cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False) cmds.delete(ch=True) cmds.hyperShade(assign=(nsTmp + ":blckMat")) cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True) else: myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat") cmds.setAttr(nsTmp + ":blckMat.color", rgb[0], rgb[1], rgb[2], typ='double3') cmds.group((nsTmp + ":*"), n=nsTmp) cmds.hyperShade(assign=(nsTmp + ":blckMat")) cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
def cenGS(): sels = cm.ls(selection=True) if len(sels) > 1: dups = cm.duplicate(sels) cm.polyUnite(sels) cm.rename('polySurface1', 'dups') bb = cm.xform('dups', q=True, bb=True, ws=True) xmax = bb[0] xmin = bb[3] ymax = bb[1] ymin = bb[4] zmax = bb[2] zmin = bb[5] x = (xmax + xmin) / 2 y = (ymax + ymin) / 2 z = (zmax + zmin) / 2 cm.spaceLocator(p=(x, y, z)) cm.delete('dups', ch=True) cm.delete('dups') elif len(sels) == 1: Loc = cm.spaceLocator(p=(0, 0, 0)) cm.matchTransform(Loc, sels)
def generate_kink_peice(cls, block_width): components = [] boolean = [] for x in range(0, block_width + 1): hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2) boolean.append(hole[0]) cmds.rotate('90deg', 0, 0, hole[0]) cmds.move(Constants["block_width_unit"] * x , 0, half(Constants["block_depth_unit"]), hole[0]) cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=Constants["block_height_unit"], depth=Constants["block_depth_unit"]) components.append(cube[0]) cmds.delete(cube[0] + ".f[40:47]") cmds.move(half(block_width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube) #caps cap_one = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"],name=get_unique_name(cls.get_prefix(), "cap")) cmds.rotate('90deg',0,0,cap_one[0]) cmds.move(0,0,half(Constants["block_depth_unit"]),cap_one[0]) cmds.delete(cap_one[0] + ".f[0:3]", cap_one[0] + ".f[14:23]", cap_one[0] + ".f[34:43]", cap_one[0] + ".f[54:63]", cap_one[0] + ".f[74:79]") components.append(cap_one[0]) #caps cap_two = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"]) cmds.rotate('90deg','180deg',0,cap_two[0]) cmds.delete(cap_two[0] + ".f[0:3]", cap_two[0] + ".f[14:23]", cap_two[0] + ".f[34:43]", cap_two[0] + ".f[54:63]", cap_two[0] + ".f[74:79]") cmds.move(block_width,0,half(Constants["block_depth_unit"]),cap_two[0]) components.append(cap_two[0]) solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), "")) boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean")) cmds.polyMergeVertex( solid[0], d=0.15 ) cmds.delete(solid[0],ch=1) return cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") )
def CombineAndMerge(self, name="combined"): original = cmds.ls(sl=True) or [] cmds.delete(constructionHistory=True) cmds.polyUnite(ch=1, mergeUVSets=1, centerPivot=True, name=name) cmds.polyMergeVertex(d=0.001, am=0, ch=1) cmds.delete(constructionHistory=True) cmds.delete(original)
def wheel(): wheelSize = cmds.intSliderGrp('WheelSize', q=True, v=True) wheelThickness = cmds.intSliderGrp('WheelThickness', q=True, v=True) rgb = cmds.colorSliderGrp('WheelColour', q=True, rgbValue=True) global nextBlockId nsTmp = "Wheel" + str(nextBlockId) hubCap(nextBlockId, wheelSize, wheelThickness) createNamespace(nsTmp) wheelSizeY = wheelThickness * .1 displaceY = (wheelThickness * .5) * .1 for i in range(0, 2): #Create cylinder cmds.polyCylinder(r=wheelSize * 0.3, h=wheelSizeY, sa=50) facetCount = cmds.polyEvaluate(nsTmp + ":pCylinder1", face=True) cmds.move((-1 * ((wheelSizeY) / 2)), nsTmp + ":pCylinder1.scalePivot", nsTmp + ":pCylinder1.rotatePivot", moveY=True, os=True) cmds.move(displaceY, moveY=True) #eliminating the non-side Faces facetCount = facetCount - 2 for j in range(0, facetCount): faceName = nsTmp + ":pCylinder1" + ".f[" + str(j) + "]" if j % 2 == 0: #Extrudes every other face cmds.polyExtrudeFacet(faceName, ltz=((wheelSize * 0.1) / 4)) cmds.rename("wheel1") cmds.select(nsTmp + ":wheel2") cmds.rotate(7.25, rotateY=True) cmds.move(((wheelThickness * .5) * .3), moveY=True) BOOLEAN(nsTmp, ":wheel1", ":wheel2", 1, "wheel") punchHole((wheelSize * .175), (wheelSizeY * 7), 0, 0, 0, nsTmp, ":wheel", "wheel") myShader = cmds.shadingNode('lambert', asShader=True, name="WheelColour") cmds.setAttr(nsTmp + ":WheelColour.color", rgb[0], rgb[1], rgb[2], typ='double3') cmds.select(nsTmp + ":wheel") cmds.rename(nsTmp) cmds.hyperShade(assign=(nsTmp + ":WheelColour")) cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True) cmds.polyUnite(nsTmp, "Hub" + str(nextBlockId - 1)) cmds.delete(ch=True) cmds.rename(nsTmp) cmds.xform(cp=True)
def combine( self ): cmds.duplicate( self.original_selected_objects, name="special_copy" ) self.selected_objects = cmds.ls( selection=True ) self.duplicate_name = self.original_selected_objects[0] + "_Combined_Copy" cmds.polyUnite( self.selected_objects, name=self.duplicate_name ) cmds.delete( constructionHistory=True ) if( len(cmds.ls( "special_copy" )) == 1 ): cmds.delete( self.selected_objects )
def CER_MergeAllMeshes(): # Select all meshes cmds.select(all=True) # Put the selection to an array selection = cmds.ls(sl=True) # If you have at least two objects, it merges them if len(selection) > 2: cmds.polyUnite(*selection, name='FinalModel')
def getRevolveValues(): # select all geometry, Unite and duplicate it cmds.select(cmds.listRelatives(cmds.ls(geometry=True), p=True, path=True), r=True) cmds.polyUnite(n='set') cmds.duplicate('set') lor = cmds.intSliderGrp(LevelsOfRevolution,q=True,v=True) rot = cmds.floatSliderGrp(rotationDistance,q=True,v=True) revolve(lor,rot)
def createGear(): teeth = 16 teethLength = 0.2 # name nsTmp = "Gear" + str(rnd.randint(1000, 9999)) cmds.select(clear=True) cmds.namespace(add=nsTmp) cmds.namespace(set=nsTmp) # query colour from UI rgb = cmds.colorSliderGrp('gearColour', q=True, rgbValue=True) # base gear = cmds.polyCylinder(r=0.7, h=0.4, sx=32) # extrude teeth for i in range(31): if (i % 2 == 0): cmds.select(gear[0] + ".f[" + str(i) + "]") cmds.polyExtrudeFacet(ltz=0.1) cmds.polyExtrudeFacet(ltz=0.1) cmds.polyMoveFacet(lsx=0.5) # decor tmp = cmds.polyCylinder(r=0.6, h=0.2) cmds.move(0.2, moveY=True, a=True) gear = cmds.polyCBoolOp(gear, tmp, op=2, ch=False) tmp = cmds.polyCylinder(r=0.6, h=0.2) cmds.move(-0.2, moveY=True, a=True) gear = cmds.polyCBoolOp(gear, tmp, op=2, ch=False) # center cylind = cmds.polyCylinder(r=0.3, h=0.6) #create x shape x = cmds.polyCube(w=0.5, h=0.6, d=0.2) tmp = cmds.polyCube(w=0.2, h=0.6, d=0.5) #combine them x = cmds.polyCBoolOp(x, tmp, op=1) x2 = cmds.duplicate(x) # remove from center cylind = cmds.polyCBoolOp(cylind, x, op=2) # remove from base gear = cmds.polyCBoolOp(gear, x2, op=2) # add material myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat") cmds.setAttr(nsTmp + ":blckMat.color", rgb[0], rgb[1], rgb[2], type='double3') cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False) cmds.move(0.3, moveY=True, a=True) cmds.delete(ch=True) cmds.hyperShade(assign=(nsTmp + ":blckMat")) cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
def getRevolveValues(): # select all geometry, Unite and duplicate it cmds.select(cmds.listRelatives(cmds.ls(geometry=True), p=True, path=True), r=True) cmds.polyUnite(n='set') cmds.duplicate('set') lor = cmds.intSliderGrp(LevelsOfRevolution, q=True, v=True) rot = cmds.floatSliderGrp(rotationDistance, q=True, v=True) revolve(lor, rot)
def applyShaders(treeHeight, planeCnt, myBranch, myLetter, season): barkMat = cmds.shadingNode('lambert', asShader=True, n='barkMat') cmds.setAttr('barkMat'+'.color', 0.45, 0.30, 0.2) #green - spring leafMat1 = cmds.shadingNode('lambert', asShader=True, n='leafMat1') cmds.setAttr('leafMat1'+'.color', 0.0, 0.90, 0.2) #green - summer leafMat2 = cmds.shadingNode('lambert', asShader=True, n='leafMat2') cmds.setAttr('leafMat2'+'.color', 0.2, 1.5, 0.0) #orange/red - fall leafMat2 = cmds.shadingNode('lambert', asShader=True, n='leafMat3') cmds.setAttr('leafMat3'+'.color', 1.5, 0.30, 0.05) #apply bark cmds.select(all=True) for i in range (1, treeHeight): cmds.select('base'+str(i), d=True) for i in range (1, planeCnt): cmds.select('leaf'+str(i), d=True) cmds.polyUnite(o=True, n='barkUnite') cmds.hyperShade(assign=barkMat) cmds.delete(ch=True) cmds.select(d = True) #apply leaf if not winter if season != 4: for i in range (1, planeCnt): cmds.select('leaf'+str(i), add=True) cmds.hyperShade(assign='leafMat'+str(season)) cmds.select('barkUnite', add=True) cmds.polyUnite(o=True, n='treeMesh') cmds.select(d=True) cmds.select('treeMesh') cmds.delete(ch=True) for i in range (1, treeHeight): cmds.select('base'+str(i), add=True) if season == 4: cmds.select('barkUnite', add=True) #select joints one by one (select all doesn't work) for h in range (1,3): maxJnts = 6 jointNum = 6 for i in range(1, myBranch[h]): maxJnts-=1 for j in range(1, maxJnts+2): cmds.select('branch'+myLetter[h]+str(i)+'_'+str(j), add=True) cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) cmds.bindSkin(tsb=True) cmds.delete(ch=True)
def slopedBlock(): blockHeight = 3 blockWidth = cmds.intSliderGrp('slopedWidth', q=True, v=True) blockDepth = cmds.intSliderGrp('slopedDepth', q=True, v=True) rgb = cmds.colorSliderGrp('slopedColour', q=True, rgbValue=True) global nextBlockId nsTmp = "Block" + str(nextBlockId) nextBlockId = nextBlockId + 1 createNamespace(nsTmp) cubeSizeX = blockWidth * 0.8 cubeSizeZ = blockDepth * 0.8 cubeSizeY = blockHeight * 0.32 cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=cubeSizeZ, sz=blockDepth) cmds.move((cubeSizeY / 2.0), y=True, a=True) for i in range(blockWidth): cmds.polyCylinder(r=0.25, h=0.20) cmds.move((cubeSizeY + 0.10), moveY=True, a=True) cmds.move(((i * 0.8) - (cubeSizeX / 2.0) + 0.4), moveX=True, a=True) cmds.move((0 - (cubeSizeZ / 2.0) + 0.4), moveZ=True) myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat") cmds.setAttr(nsTmp + ":blckMat.color", rgb[0], rgb[1], rgb[2], typ='double3') cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False) cmds.delete(ch=True) cmds.hyperShade(assign=(nsTmp + ":blckMat")) cmds.select((nsTmp + ":" + nsTmp + ".e[1]"), r=True) cmds.move(0, -0.8, 0, r=True) if blockDepth == 4: tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[8]"), q=True, t=True) cmds.select((nsTmp + ":" + nsTmp + ".vtx[6]"), r=True) cmds.move(tV[0], tV[1], tV[2], a=True) tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[9]"), q=True, t=True) cmds.select((nsTmp + ":" + nsTmp + ".vtx[7]"), r=True) cmds.move(tV[0], tV[1], tV[2], a=True) if blockDepth >= 3: tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[6]"), q=True, t=True) cmds.select((nsTmp + ":" + nsTmp + ".vtx[4]"), r=True) cmds.move(tV[0], tV[1], tV[2], a=True) tV = cmds.xform((nsTmp + ":" + nsTmp + ".vtx[7]"), q=True, t=True) cmds.select((nsTmp + ":" + nsTmp + ".vtx[5]"), r=True) cmds.move(tV[0], tV[1], tV[2], a=True) cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
def fnCreateFactor(lstChunkedUp, intFactor): lstTranches = [] for intChunkNum in range(0, len(lstChunkedUp)): strPolyName = cmds.polyCube(sx=1, sy=1,sz=1, cuv=0, w=fltSize, h=fltSize, d=fltSize, name='STVPolyBase')[0] #create the shape strTrancheName = fnUniteMesh(lstChunkedUp[intChunkNum], intChunkNum, strPolyName) lstTranches.append(strTrancheName) strFactor = 'STVPoly_Factor_' + str(intFactor) cmds.polyUnite(lstTranches, n=strFactor) cmds.delete(strFactor, ch=True) return(strFactor)
def constrainCapeChain(): # Create a global position locator for Beowulf's main rig control location globalPos = mc.spaceLocator(p=[0, 0, 0]) globPos = mc.rename(globalPos, "beowulfGlobalPos") mc.select(rigPrefix + "Beowulf_primary_global_cc_01") mc.select(globPos, add=True) mc.pointConstraint( offset=[0, 0, 0], weight=1 ) #constrains the globPos position to where Beowulf's rig_main is mc.orientConstraint( offset=[0, 0, 0], weight=1) #orients the globPos to match Beowulf's rig_main # Get transformation variables from globPos locator tx = mc.getAttr(globPos + ".translateX") ty = mc.getAttr(globPos + ".translateY") tz = mc.getAttr(globPos + ".translateZ") rx = mc.getAttr(globPos + ".rotateX") ry = mc.getAttr(globPos + ".rotateY") rz = mc.getAttr(globPos + ".rotateZ") mc.setAttr("beowulf_cape_model_main_Beowulf_Cape.translateX", tx) mc.setAttr("beowulf_cape_model_main_Beowulf_Cape.translateY", ty) mc.setAttr("beowulf_cape_model_main_Beowulf_Cape.translateZ", tz) mc.setAttr("beowulf_cape_model_main_Beowulf_Cape.rotateX", rx) mc.setAttr("beowulf_cape_model_main_Beowulf_Cape.rotateY", ry) mc.setAttr("beowulf_cape_model_main_Beowulf_Cape.rotateZ", rz) #Hide meshes we don't want to work with right now mc.hide('beowulf_cape_model_main_beowulf_cape_simMesh') mc.hide('beowulf_cape_model_main_beowulf_cape_beautyMesh') #Select & combine the clasps & chain meshes mc.select("beowulf_cape_model_main_beowulf_cape_clasps", replace=True) mc.select("beowulf_cape_model_main_beowulf_cape_clasp_chain", add=True) mc.polyUnite("beowulf_cape_model_main_beowulf_cape_clasps", "beowulf_cape_model_main_beowulf_cape_clasp_chain", name="beowulf_cape_model_main_beowulf_capeChain_combined") #center the combined object's pivot so we can rotate it to look more normal mc.xform("beowulf_cape_model_main_beowulf_capeChain_combined", centerPivots=True) #Select the rig control we want to parent the chain/clasp to mc.select(rigPrefix + "Beowulf_chest_cc_01", replace=True) #Now select the chainCombined object mc.select("beowulf_cape_model_main_beowulf_capeChain_combined", add=True) #Create parent constraint: (targetObject, childObject) mc.parentConstraint(rigPrefix + "Beowulf_chest_cc_01", "beowulf_cape_model_main_beowulf_capeChain_combined", maintainOffset=1, weight=1.0) #Hide original chain/clasp because we don't need them for this part mc.hide('beowulf_cape_model_main_beowulf_cape_clasps') mc.hide('beowulf_cape_model_main_beowulf_cape_clasp_chain')
def mirrorPieces(arg): L = mc.radioButton(buttomL, q=1, select=True) R = mc.radioButton(buttomR, q=1, select=True) C = mc.radioButton(buttomC, q=1, select=True) if L: side = 'L' elif R: side = 'R' elif C: side = 'C' sel = mc.ls(sl=True) for o in sel: # Mirror the piece if mc.nodeType(mc.listRelatives(o)[0]) == 'mesh': if mc.objExists(o + '_mirror') == False: mirroredGeo = '' attrs = mc.listAttr(o, keyable=1) for attr in attrs: mc.setAttr(o + "." + attr, lock=0) mc.xform(o, ws=True, piv=(0, 0, 0)) mc.makeIdentity(o, translate=1, rotate=1, scale=True, apply=True) mirroredGeo = mc.duplicate(o, n=o + '_mirror')[0] mc.setAttr(mirroredGeo + '.scaleX', -1) mc.makeIdentity(mirroredGeo, translate=1, rotate=1, scale=True, apply=True) mc.polyNormal(mirroredGeo, normalMode=0, userNormalMode=0) if 'L_' in mirroredGeo: mc.rename(mirroredGeo, o.replace('L_', 'R_')) elif 'R_' in mirroredGeo: mc.rename(mirroredGeo, o.replace('R_', 'L_')) elif 'Left' in mirroredGeo: mc.rename(mirroredGeo, o.replace('Left', 'Right')) elif 'Right' in mirroredGeo: mc.rename(mirroredGeo, o.replace('Right', 'Left')) elif 'Mid' or 'C_' or 'mid' in mirroredGeo or None == mirroredGeo: mc.polyUnite(o, mirroredGeo, name=str(o), constructionHistory=1, mergeUVSets=1, caching=True) mc.delete(mirroredGeo, ch=True) mc.rename(mirroredGeo, str(o)) mc.polyMergeVertex(mirroredGeo, d=0.379) else: print 'Ya existe el mirror.' else: print 'No es una geometria'
def selectAllDelHis(number): cmds.select(all=True) if (number != 1): cmds.polyUnite(n='combined') cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) cmds.delete(constructionHistory=True) if (cmds.objExists('combined')): cmds.xform('combined', cp=1) else: print('error')
def createHat(cone_colour=None, pompom_colour=None): # Create the cone and pompom cone_obj, cone_node = cmds.polyCone() pompom_obj, pompom_node = cmds.polySphere(r=0.25) #move the pompom to the right spot on the hat cone while it's still selected cmds.move(0, 1.06, 0) change_colour(cone_obj, 'blinn', cone_colour) change_colour(pompom_obj, 'lambert', pompom_colour) # merge them into one shape (polyUnite) cmds.polyUnite(cone_obj, pompom_obj, n='hat')
def basicBlock(): # query values from UI sliders height = cmds.intSliderGrp('height', q=True, v=True) width = cmds.intSliderGrp('blockWidth', q=True, v=True) length = cmds.intSliderGrp('blockLength', q=True, v=True) rgb = cmds.colorSliderGrp('blockColour', q=True, rgbValue=True) # name nsTmp = "Block" + str(rnd.randint(1000, 9999)) cmds.select(clear=True) cmds.namespace(add=nsTmp) cmds.namespace(set=nsTmp) # define a cube's size cubeSizeX = width * 0.8 cubeSizeZ = length * 0.8 cubeSizeY = height * 0.32 # create a cube cmds.polyCube(h=cubeSizeY, w=cubeSizeX, d=cubeSizeZ) # move block half size up on Y axis cmds.move((cubeSizeY / 2.0), moveY=True) # loop through width and length (in bumps) for i in range(width): for j in range(length): # create cylinder cmds.polyCylinder(r=0.25, h=0.20) # move it on Y axis cmds.move((cubeSizeY + 0.10), moveY=True, a=True) # move it on X axis cmds.move(((i * 0.8) - (cubeSizeX / 2.0) + 0.4), moveX=True, a=True) # move it on Z axis cmds.move(((j * 0.8) - (cubeSizeZ / 2.0) + 0.4), moveZ=True, a=True) # add material myShader = cmds.shadingNode('lambert', asShader=True, name="blckMat") cmds.setAttr(nsTmp + ":blckMat.color", rgb[0], rgb[1], rgb[2], type='double3') cmds.polyUnite((nsTmp + ":*"), n=nsTmp, ch=False) cmds.delete(ch=True) cmds.hyperShade(assign=(nsTmp + ":blckMat")) cmds.namespace(removeNamespace=":" + nsTmp, mergeNamespaceWithParent=True)
def GEO_clear_combine_selection(): ''' combines selection and deletes history ''' sel = cmds.ls(sl=True) meshes = cmds.listRelatives(sel, pa=True, type="mesh") all_sel = cmds.listRelatives(meshes, parent=True, fullPath=False) if all_sel is None: return "Select Meshes first.", 0 try: cmds.polyUnite(sel, ch=False) # combines and deletehistory except RuntimeError as e: return str(e), 0 return "Shapes combined with no history: ({})".format(len(all_sel)), 1
def CreateNewUVSetAndCombine(): newSelectionList = [] selectionList = Cmds.ls(sl=True) Cmds.select(cl=True) for selection in selectionList: Cmds.select(selection, add=True) if not "CosmopolisUVSet" in Cmds.polyUVSet( selection, query=True, allUVSets=True): Cmds.polyUVSet(selection, rename=True, newUVSet='CosmopolisUVSet') Cmds.polyUVSet(selection, currentUVSet=True, uvSet='CosmopolisUVSet') Cmds.polyUnite(ch=True) Cmds.polyUVSet(currentUVSet=True, uvSet='CosmopolisUVSet')
def moveBeam(multiShape, width, width2): temp = str(cu[0]).rsplit("'", 1)[0] temp2 = temp.rsplit("'", 1)[1] temp2 = str(temp2) cmds.move((-width2 / 5.0), temp2 + ".rotatePivot", moveX=True) cmds.move(0.31, temp2 + ".rotatePivot", moveY=True) cmds.rotate(0, 0, angleChoice) cmds.move(((width) + float(width2)) / 2.5, moveX=True) cmds.delete(ch=True) cmds.polyUnite(multiShape[0], multiShape[1], n="block", ch=False)
def HoleBlock(): # Initialize the building blocks and the subtraction blocks components = [] subtracts = [] blockDepth = cmds.intSliderGrp('HoleblockDepth', query=True, value=True) rgb = cmds.colorSliderGrp('HoleblockColour', query=True, rgbValue=True) cmds.select(clear=True) blockWidth = 1 cubeDimX = blockWidth * 0.8 blockHeight = 1 cubeDimY = blockHeight * 0.96 cubeDimZ = blockDepth * 0.8 cube = cmds.polyCube(h=cubeDimY, w=cubeDimX, d=cubeDimZ, sz=blockDepth) cmds.move((cubeDimY / 2.0), moveY=True) # Pipes on top of block for i in range(blockDepth): components.append(cmds.polyPipe(r=0.24, h=0.36, thickness=0.09)[0]) cmds.move((cubeDimY + 0.10), moveY=True, a=True) cmds.move(((i * 0.8) - (cubeDimZ / 2.0) + 0.4), moveZ=True, a=True) # Holes within block for k in range(blockDepth - 1): holes = cmds.polyCylinder(h=1, r=0.24, ax=(1, 0, 0)) subtracts.append(holes[0]) cmds.move(0, cubeDimY - 0.38, ((k * 0.8) - (cubeDimZ / 2.0) + 0.8), holes[0], a=True) # Unite the cube and the top addShape = cmds.polyUnite(cube, components, ch=False) currentHole = subtracts[0] for hole in range(len(subtracts) - 1): uniteHole = cmds.polyUnite(currentHole, subtracts[hole + 1], ch=False) currentHole = uniteHole finalShape = cmds.polyCBoolOp(addShape, uniteHole, op=2, ch=False)[0] # Adding on the colour myShader = cmds.shadingNode('lambert', asShader=True, name="blockMaterial") cmds.setAttr(myShader + ".color", rgb[0], rgb[1], rgb[2], type='double3') cmds.select(finalShape, r=True) cmds.hyperShade(assign=myShader) cmds.namespace(set=":")
def createTire(): global cu cu = cmds.polyTorus(sx=2, sy=2, r=0.5, sr=0.25) cmds.scale(1, 1.712, 1) cmds.delete(ch=True) middle = cmds.polyCylinder(r=0.45, h=2, sz=4, sy=12) cu[0] = cmds.polyBoolOp(cu[0], middle[0], op=2, n="block", ch=False) extrudeForTire() cmds.delete(ch=True) pip1 = cmds.polyPipe(r=0.4906, h=1.5094, t=0.0755) cu[0] = cmds.polyUnite(cu[0], pip1[0], n="block", ch=False) pip2 = cmds.polyPipe(r=0.4150, h=1.1321, t=0.0) cu[0] = cmds.polyUnite(cu[0], pip2[0], n="block", ch=False)
def fnUniteMesh(lstChunk, intChunkNumber, strPName): lstSelectedObjects = cmds.ls('STVPoly*') lstTranche = [] for lstObj in lstChunk: fltAdjTemp = fnTempScalar(float(lstObj[2])) strInts = fnCreateCylinder(int(lstObj[1]), int(lstObj[0]), fltAdjTemp, str(lstObj[3]), strPName) #NEED to add function here for temp lstTranche.append(strInts) lstSelectedObjects = cmds.ls('STVPoly*') if len(lstTranche) > 1: strPolyMeshName = 'STVPolyMesh_Factor' + str(lstObj[3]) + '_Tranche_' + str(intChunkNumber) cmds.polyUnite(lstTranche, n=strPolyMeshName) cmds.delete(strPolyMeshName, ch=True) cmds.delete(lstTranche) return(strPolyMeshName)
def os_mergeGroups(): sel = mc.ls(sl = True) for each in sel: c = mc.listRelatives(each,c = True, ad = True, type = 'transform') geoArr = [] for child in c: if '_geo' in child: geoArr.append(child) print each+' : '+str(len(geoArr)) + ' geos combined.' if len(geoArr) == 1: mc.parent(geoArr[0], w=True) else: mc.polyUnite (each, ch = 0, mergeUVSets = 1, centerPivot = True, name = each)
def fn_createObject_PolyCreate(): global importedObj objList = [] for p in range(0, len(importedObj.polys), 1): facelist = [] for v in range(0, len(importedObj.polys[p]), 1): pVert = importedObj.vertices[importedObj.polys[p][v]] facelist.append(pVert) objList.append((cmds.polyCreateFacet(p=facelist, ch=False))[0]) cmds.polyUnite(objList, ch=False, n=importObjectName)
def __init__(self, name_, height, radius, sides, shader): ''' Initializes a CylinderHouse object, and creates a polygonal house object based on a cylinder primitive. self: Object that is to be initialized. name_: A string with the name the polygonal house object will have. height: The height of the house. radius: See Attributes. sides: See Attributes. shader: Shader that will be assigned to the house. On exit: A CylinderHouse object has been initialized and a polygonal house has been created out of a cylinder primitive. A foundation for the house has also been created and united with the box. The given shader has been assigned to the house. ''' House.__init__(self, name_, "cylinder", height, radius * 2, radius * 2) self.radius = radius self.sides = sides n = cmds.polyCylinder(n = name_, r = radius, h = height, sx = sides, sy = height) cmds.xform(n[0], translation = (0,height/2.0,0)) f = cmds.polyCylinder(n = "foundation", r = radius + 0.15, height = 0.8, sx = sides) cmds.xform(f[0], translation = (0, 0.4, 0)) n = cmds.polyUnite(n[0],f[0], n = name_) self.name = n[0] cmds.sets(n[0], edit=True, forceElement= shader[1]) cmds.delete(self.name, ch = True)
def __init__(self, name_, height, radius, sides, thickness, shader): ''' Initializes a PipeHouse object, and creates a polygonal house object based on a pipe primitive. self: Object that is to be initialized. name_: A string with the name the polygonal house object will have. height: The height of the house. radius: See Attributes. sides: See Attributes. thickness: See Attributes. shader: Shader that will be assigned to the house. On exit: A PipeHouse object has been initialized and a polygonal house has been created out of a pipe primitive. A foundation for the house has also been created and united with the box. The given shader has been assigned to the house. ''' House.__init__(self, name_, "pipe", height, radius * 2, radius * 2) self.radius = radius self.sides = sides self.thickness = thickness # The actual height of a pipe object in maya is half of the height it is given. Therefore here h = 2 * height. n = cmds.polyPipe(n = name_, r = radius, h = 2 * height, t = thickness, sa = sides, sh = height) cmds.xform(n[0], translation = (0,height/2.0,0)) f = cmds.polyPipe(n = "foundation", r = radius + 0.15, height = 0.8 * 2, t = thickness + 0.3, sa = sides) cmds.xform(f[0], translation = (0, 0.4, 0)) n = cmds.polyUnite(n[0],f[0], n = name_) self.name = n[0] cmds.sets(n[0], edit=True, forceElement=shader[1]) cmds.delete(self.name, ch = True)
def combine(): """ a cleaner combine """ selection = cmds.ls(sl=True, type='mesh', dag=True) if not selection or selection < 2: cmds.warning('Please select at least 2 meshes!') # get full path meshFull = cmds.listRelatives(selection[0], p=True, f=True) # get parent meshParent = cmds.listRelatives(meshFull, p=True, f=True) meshInWorld = [] if meshParent: meshParent0 = meshParent[0] meshInWorld.append(cmds.parent(meshFull, world=True)[0]) else: meshInWorld = meshFull # replace 1st mesh in sel by mesh in world selection[0] = meshInWorld[0] # get pivots pivots = cmds.xform(meshInWorld[0], q=True, ws=True, a=True, rotatePivot=True) # combine & rename newMesh = cmds.polyUnite(selection, o=True) newMeshName = cmds.rename(newMesh[0], meshInWorld[0]) # set pivot cmds.xform(newMeshName, rotatePivot=pivots) # reparent if meshParent: newMeshName = cmds.parent(newMeshName, meshParent, a=True) # delete history cmds.delete(newMeshName, ch=True, hi='none')
def roundPlate(): #get values from UI rgb = cmds.colorSliderGrp('brickColour', query=True, rgbValue=True) transparent = cmds.checkBox('makeTransparent', query = True, value = True) base = cmds.polyCylinder( h = 0.18, r = 0.3 ) cmds.rotate( 90, rotateY = True ) cmds.move( 0.18/2, moveY = True) wide = cmds.polyCylinder( h = 0.14, r = 0.4 ) cmds.rotate( 90, rotateY = True ) cmds.move( 0.18 + (0.14/2), moveY = True) stud = cmds.polyCylinder( h = 0.18, r = 0.24 ) cmds.rotate( 90, rotateY = True ) cmds.move( 0.18 + 0.14 + (0.18/2), moveY = True) rp = cmds.polyUnite( base, wide, stud ) myShader = cmds.shadingNode( 'phong', asShader=True ) cmds.setAttr( myShader+".color", rgb[0], rgb[1], rgb[2], type='double3') cmds.setAttr( myShader+".reflectivity", 0 ) if( transparent == True ): cmds.setAttr( myShader+".transparency", 0.5, 0.5, 0.5, type = 'double3' ) cmds.select( rp ) cmds.hyperShade( assign = myShader ) cmds.delete( ch = True )
def movePolysFromObj(): """ # 1. Select faces # 2. Shift-select targetObj # 3. Run """ selFaces = mc.ls(os=1, fl=1)[:-1] selFacesIds = [int(faceName.split("[")[1][:-1]) for faceName in selFaces] # target object is the last selected item targetObj = mc.ls(os=1, fl=1)[-1] targetObjParent = mc.listRelatives(targetObj, p=1)[0] # delete the parentConstraint if necessary targetObjChildren = mc.listRelatives(targetObj, c=1, type="parentConstraint") if not targetObjChildren == None: mc.delete(targetObjChildren) srcObj = selFaces[0].split(".")[0] tempObj = mc.duplicate(srcObj, n="tempObj")[0] mc.delete(selFaces) facesToCopy = [faceName.replace(srcObj, tempObj) for faceName in selFaces] mc.select(facesToCopy, r=1) meval("InvertSelection;") mc.delete() combinedGeo = mc.polyUnite(tempObj, targetObj, ch=0, n="combinedGeo")[0] mc.rename(combinedGeo, targetObj) mc.parent(targetObj, targetObjParent) mc.polyMergeVertex(targetObj, d=0.001, ch=0) mc.delete(tempObj) mc.select(srcObj, r=1)
def separateMeshsBySkinWeight2( meshObjs ): import sgBFunction_connection import sgBFunction_dag meshObjs = sgBFunction_dag.getChildrenMeshExists( meshObjs ) meshs = [] for meshObj in meshObjs: meshs += separateMeshBySkinWeight2( meshObj ) jntAndBindTargets = {} appendedJnts = [] for sel in meshs: mmdc = cmds.listConnections( sel, s=1, d=0 )[0] bindObj = cmds.listConnections( mmdc, s=1, d=0 )[0] bindObjP = cmds.listRelatives( bindObj, p=1, f=1 )[0] if not bindObjP in appendedJnts: appendedJnts.append( bindObjP ) jntAndBindTargets.update( {bindObjP:[]} ) jntAndBindTargets[ bindObjP ].append( sel ) for jnt, bindObjs in jntAndBindTargets.items(): if len( bindObjs ) == 1: continue bindObj, polyUnite = cmds.polyUnite( bindObjs, n=bindObjs[0] ) bindObj = cmds.rename( bindObj, jnt.split( '|' )[-1]+'_mesh' ) sgBFunction_connection.bindConnect( bindObj, jnt )
def generate(cls, *args): components = [] width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True) height = cmds.intSliderGrp(cls.get_prefix() + Labels["height_label"], query=True, value=True) depth = cmds.intSliderGrp(cls.get_prefix() + Labels["depth_label"], query=True, value=True) rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True) block_width = width * Constants["block_width_unit"] block_height = height * Constants["block_height_unit"] block_depth = depth * Constants["block_depth_unit"] #stubs for x in range(0, width): for z in range(0, depth): stub = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Stub"), radius=Constants["stub_radius"], height = Constants["stub_height"]) components.append(stub[0]) cmds.move(Constants["block_width_unit"] * x + half(Constants["block_width_unit"]), half(Constants["block_height_unit"]) * height + half(Constants["stub_height"]), Constants["block_depth_unit"] * z + half(Constants["block_depth_unit"]), stub[0]) cube = cmds.polyCube(name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth) components.append(cube[0]) cmds.move(half(width * Constants["block_width_unit"]), 0, half(depth * Constants["block_depth_unit"]), cube) if components.count > 1: final = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), "")) else: final = components[0] shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat")) cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3') cmds.select(final[0], r=True) cmds.hyperShade(assign=shader)
def makeRowOfStreetTrees(num, coor, shaders, dir): ''' Makes a row with the specified number of street trees. num: Number of street trees in the row. coor: A tuple with the x- and z- coordinates the center of the row of trees will be located at. shaders: A list of shaders for the tree crowns. dir: String which specifies if the trees should be placed along the x-axis (horisontal) or along the z-axis (vertical). On exit: The specified number of trees has been created using makeStreetTree(...), and placed in a row at the given coordinates. All of the trees are combined and the resulting object is returned as a tuple with the object name and node name. ''' start = -(num - 1)/2.0 * 2.8 tree = makeStreetTree(shaders) cmds.xform(tree[0], t = (start, 0, 0), ws = True) for i in range(1,num): tree1 = makeStreetTree(shaders) cmds.xform(tree1[0], t = (start + i * 2.8, 0, 0), ws = True) tree = cmds.polyUnite(tree[0], tree1[0]) cmds.xform(tree[0], centerPivots = True) if dir == "vertical": cmds.rotate(90, y = True) cmds.xform(tree[0], translation = (coor[0], 0,coor[1]), ws = True) return tree
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 makeFountain(): ''' Creates a fountain. On exit: A fountain shaped polygonal object has been created, assigned a shader and is returned as a tuple with the object name and node name. The procedure uses random numbers in order to create different looking fountains every time it is called. ''' steps = random.randint(1,3) fountain = cmds.polyCylinder(name = "Fountain", h = 0.1) cmds.xform(fountain, translation = (0, 0.25, 0)) cmds.select(fountain[0] + ".f[40:59]") for i in range(steps): scale_ = random.uniform(0.6, 0.95) cmds.polyExtrudeFacet(scale = (scale_, scale_, scale_)) translation = random.uniform(0.1, 0.6) cmds.polyExtrudeFacet(translate = (0, translation, 0)) cmds.polyExtrudeFacet(scale = (0.9,0.9,0.9)) cmds.polyExtrudeFacet(translate = (0, -0.3,0)) scale_ = random.uniform(0.3,0.6) cmds.polyExtrudeFacet(scale = (scale_,scale_,scale_)) translation = random.uniform(0.2,0.4) cmds.polyExtrudeFacet(translate = (0,translation,0)) stepsUp = random.randint(1,3) for i in range(stepsUp): scale_ = random.uniform(0.4,0.9) cmds.polyExtrudeFacet(scale = (scale_,scale_,scale_)) translation = random.uniform(0.05,1) cmds.polyExtrudeFacet(translate = (0,translation,0)) top = fountainTop(fountain) # Create a top for the fountain. fountain = cmds.polyUnite(top[0],fountain) cmds.sets(fountain[0], edit=True, forceElement="fountainMaterialGroup") return fountain
def fxCombine(merge=False): targets = m.ls(sl=True, l=True) if not targets: return parent = m.listRelatives(targets[0], p=True, pa=True) try: combineResult = m.polyUnite(targets) except RuntimeError: m.error('Invalid selection for combine operation.') return if parent: combineResult = m.parent(combineResult[0], parent[0]) m.delete(combineResult[0], ch=True) for t in targets: if m.objExists(t): m.delete(t) finalObject = m.rename(combineResult[0], getShortName(targets[0])) m.select(finalObject) if merge: meval('performPolyMerge 0') m.polyOptions(finalObject, displayBorder=True, sizeBorder=4) m.select(finalObject)
def __init__(self, name_, height, width, depth, shader): ''' Initializes a BoxHouse object, and creates a polygonal house object based on a box primitive. self: Object that is to be initialized. name_: name_: A string with the name the polygonal house object will have. height: The height of the house. width: The width of the house. depth: The depth of the house. shader: Shader that will be assigned to the house. On exit: A BoxHouse object has been initialized and a polygonal house has been created out of a box primitive. A foundation for the house has also been created and united with the box. The given shader has been assigned to the house. ''' House.__init__(self, name_, "box", height, width, depth) n = cmds.polyCube(n = "house_", w = width, h = height, d = depth, sy = height) cmds.xform(n[0], translation = (0, height/2.0, 0)) f = cmds.polyCube(n = "foundation", w = width + 0.3, h = 0.8, d = depth + 0.3) cmds.xform(f[0], translation = (0,0.4,0)) n = cmds.polyUnite(n[0],f[0], n = name_) self.name = n[0] cmds.sets(n[0], edit=True, forceElement= shader[1]) cmds.delete(self.name, ch = True)
def pointFaceMesh(pointList,scale=0.05,combine=True,prefix='pointFace'): ''' ''' # Get encoded point list ptList = [] for point in pointList: ptList.append(glTools.utils.base.getPosition(point)) # Create face for each point faceList = [] vscale = scale * 0.5 hscale = scale * 0.866 for pt in ptList: face = mc.polyCreateFacet(p=[(pt[0],pt[1]+scale,pt[2]),(pt[0]+hscale,pt[1]-vscale,pt[2]),(pt[0]-hscale,pt[1]-vscale,pt[2])])[0] face = mc.rename(face,prefix+'_mesh') faceList.append(face) # Define return list mesh = faceList # Combine faces to single mesh if combine: mesh = mc.polyUnite(faceList,ch=False) mesh = [mc.rename(mesh[0],prefix+'_mesh')] # Return result return mesh
def combine(self, objs=[], new_name="", keepHistory=0): ''' Combines the geometry and stores the names. This is useful for speeding up the rigs and seperating in a predictible way. @param objs: Mesh objects to combine @type objs: list @param new_name: New name for the combined mesh @type new_name: str @param keepHistory: Maintain history after function has completed @type keepHistory: bool ''' # Check input arguments if not objs: raise Exception('Input list "objs" is not a valid list!') for obj in objs: if not mc.objExists(obj): raise Exception('Object '+obj+' does not exist!') if mc.objExists(new_name): raise Exception('An object of name '+new_name+' already exists! Please choose another name!') # Combine multiple mesh objects to a single mesh new_obj = mc.polyUnite(objs, n=new_name) mc.addAttr( new_obj[0], ln='origNames', dt='string', multi=True) # Recond original names list on new mesh transform for i in range(len(objs)): mc.setAttr( new_obj[0]+'.origNames['+str(i)+']', objs[i], type='string') # Delete history if not keepHistory : mc.delete(new_obj[1]) mc.delete(objs) return new_obj[0]
def Lab_coordinates_system_representation(): """ Creates a *CIE L\\*a\\*b\\** coordinates system representation. Returns ------- bool Definition success. """ group = cmds.createNode('transform') cube = cmds.polyCube(w=600, h=100, d=600, sx=12, sy=2, sz=12, ch=False)[0] set_attributes({'{0}.translateY'.format(cube): 50, '{0}.overrideEnabled'.format(cube): True, '{0}.overrideDisplayType'.format(cube): 2, '{0}.overrideShading'.format(cube): False}) cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True) cmds.select(['{0}.f[0:167]'.format(cube), '{0}.f[336:359]'.format(cube)]) cmds.delete() cmds.nurbsToPolygonsPref(polyType=1, chordHeightRatio=0.975) for label, position, name in (('-a*', (-350, 0), 'minus_a'), ('+a*', (350, 0), 'plus_a'), ('-b*', (0, 350), 'minus_b'), ('+b*', (0, -350), 'plus_b')): curves = cmds.listRelatives( cmds.textCurves(f='Arial Black Bold', t=label)[0]) mesh = cmds.polyUnite(*[cmds.planarSrf(x, ch=False, o=True, po=1) for x in curves], ch=False)[0] cmds.xform(mesh, cp=True) cmds.xform(mesh, translation=(0, 0, 0), absolute=True) cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True) cmds.select(mesh) cmds.polyColorPerVertex(rgb=(0, 0, 0), cdo=True) set_attributes({'{0}.translateX'.format(mesh): position[0], '{0}.translateZ'.format(mesh): position[1], '{0}.rotateX'.format(mesh): -90, '{0}.scaleX'.format(mesh): 50, '{0}.scaleY'.format(mesh): 50, '{0}.scaleY'.format(mesh): 50, '{0}.overrideEnabled'.format(mesh): True, '{0}.overrideDisplayType'.format(mesh): 2}) cmds.delete(cmds.listRelatives(curves, parent=True)) cmds.makeIdentity(mesh, apply=True, t=True, r=True, s=True) mesh = cmds.rename(mesh, name) cmds.parent(mesh, group) cube = cmds.rename(cube, 'grid') cmds.parent(cube, group) cmds.rename(group, 'Lab_coordinates_system_representation') return True
def generate(cls, *args): components = [] boolean = [] width = cmds.intSliderGrp(cls.get_prefix() + Labels["width_label"], query=True, value=True) rgb = cmds.colorSliderGrp(cls.get_prefix() + Labels["color_label"], query=True, rgbValue=True) block_width = width * Constants["block_width_unit"] block_height = Constants["block_height_unit"] block_depth = Constants["block_depth_unit"] for x in range(0, width + 1): hole = cmds.polyCylinder(name=get_unique_name(cls.get_prefix(), "Hole"), radius=Constants["perforation_radius"], height=Constants["block_depth_unit"] + 0.2) boolean.append(hole[0]) cmds.rotate('90deg', 0, 0, hole[0]) cmds.move(Constants["block_width_unit"] * x , 0, half(Constants["block_depth_unit"]), hole[0]) cube = cmds.polyCube(sx=5,sy=2,sz=2,name=get_unique_name(cls.get_prefix(), "block"), width=block_width, height=block_height, depth=block_depth) components.append(cube[0]) cmds.delete(cube[0] + ".f[40:47]") cmds.move(half(width * Constants["block_width_unit"]), 0, half(Constants["block_depth_unit"]), cube) #caps cap_one = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"],name=get_unique_name(cls.get_prefix(), "cap")) cmds.rotate('90deg',0,0,cap_one[0]) cmds.move(0,0,half(Constants["block_depth_unit"]),cap_one[0]) cmds.delete(cap_one[0] + ".f[0:3]", cap_one[0] + ".f[14:23]", cap_one[0] + ".f[34:43]", cap_one[0] + ".f[54:63]", cap_one[0] + ".f[74:79]") components.append(cap_one[0]) #caps cap_two = cmds.polyCylinder(sc=1, sy=2, radius=half(Constants["block_height_unit"]), height=Constants["block_depth_unit"]) cmds.rotate('90deg','180deg',0,cap_two[0]) cmds.delete(cap_two[0] + ".f[0:3]", cap_two[0] + ".f[14:23]", cap_two[0] + ".f[34:43]", cap_two[0] + ".f[54:63]", cap_two[0] + ".f[74:79]") cmds.move(block_width,0,half(Constants["block_depth_unit"]),cap_two[0]) components.append(cap_two[0]) solid = cmds.polyUnite(components, name=get_unique_name(cls.get_prefix(), "")) boolean_group = cmds.polyUnite(boolean, name=get_unique_name(cls.get_prefix(),"boolean")) cmds.polyMergeVertex( solid[0], d=0.15 ) cmds.delete(solid[0],ch=1) final = cmds.polyBoolOp( solid[0], boolean_group[0], op=2, n=get_unique_name(cls.get_prefix(), "") ) shader = cmds.shadingNode('blinn', asShader=True, name=get_unique_name(cls.get_prefix(),"mat")) cmds.setAttr(shader + ".color", rgb[0],rgb[1],rgb[2], type='double3') cmds.select(final[0], r=True) cmds.hyperShade(assign=shader)
def makeFence(startPoint, endPoint, axis): ''' Creates a fence between two points along either the x-axis or the z-axis. startPoint: Tuple with the coordinates where the fence will start. endPoint: Tuple with the coordinates where the fence will end. axis: String that specifies along which axis the fence will be created. On exit: A fence polygonal object has been created between the specified points and a shader has been assigned to it. The fence object is returned as a tuple with the object name and the node name. ''' if axis == "x": length = abs(startPoint[0] - endPoint[0]) poleNumber = int(length / 0.8) if poleNumber != 0: distance = float(endPoint[0] - startPoint[0]) / poleNumber else: distance = 0 bar = cmds.polyCube(name = "bar", h = 0.05, w = length, d = 0.05) cmds.xform(bar,translation = (startPoint[0] + (endPoint[0] - startPoint[0])/2.0,0.8,startPoint[1])) bar2 = cmds.duplicate(bar[0]) cmds.xform(bar2, translation = (0,-0.3,0), r = True) fence = cmds.polyUnite(bar,bar2) for i in range(poleNumber + 1): pole = cmds.polyCube(name = "pole", h = 0.7, w = 0.1, d = 0.05) cmds.xform(pole[0], translation = (startPoint[0] + i * distance,0.55,startPoint[1])) fence = cmds.polyUnite(pole,fence) else: length = abs(startPoint[1] - endPoint[1]) poleNumber = int(length / 0.8) if poleNumber != 0: distance = float(endPoint[1] - startPoint[1]) / poleNumber else: distance = 0 bar = cmds.polyCube(name = "bar", h = 0.05, w = 0.05, d = length) cmds.xform(bar,translation = (startPoint[0],0.8,startPoint[1]+ (endPoint[1] - startPoint[1])/2.0)) bar2 = cmds.duplicate(bar[0]) cmds.xform(bar2, translation = (0,-0.3,0), r = True) fence = cmds.polyUnite(bar,bar2) for i in range(poleNumber + 1): pole = cmds.polyCube(name = "pole", h = 0.7, w = 0.05, d = 0.1) cmds.xform(pole[0], translation = (startPoint[0],0.55,startPoint[1] + i * distance)) fence = cmds.polyUnite(pole,fence) cmds.sets(fence[0], edit=True, forceElement="fenceMaterialGroup") return fence
def createBlockHoles( blockSizeX, blockSizeY, block, blockLength, blockOffset ): hcList = [] rcyList = [] rcuList = [] for j in range( blockLength ): #create cylinders to cut holes holeCylinder = cmds.polyCylinder( r = 0.24, h = 2, sz=1 ) cmds.rotate( 90, rotateX = True ) cmds.move((blockSizeY/2), moveY = True, a = True) cmds.move(((j * 0.8) - (blockSizeX/2.0) + blockOffset ), moveX = True, a = True) hcList.append( holeCylinder ) #create cylinders to cut sunken area around holes ##create a cylinder ridgeCylinder = cmds.polyCylinder( r=0.31, h=2, sz=1 ) cmds.rotate( 90, rotateX = True ) cmds.move((blockSizeY/2), moveY = True, a = True) cmds.move(((j * 0.8) - (blockSizeX/2.0) + blockOffset ), moveX = True, a = True) rcyList.append( ridgeCylinder ) ##create a cube ridgeCube = cmds.polyCube ( h = 0.64, w = blockSizeY, d = blockSizeY ) cmds.rotate( 90, rotateX = True ) cmds.move((blockSizeY/2), moveY=True ) cmds.move(((j * 0.8) - (blockSizeX/2.0) + blockOffset ), moveX=True ) rcuList.append( ridgeCube ) if len( hcList ) > 1 : holeCylinders = cmds.polyUnite( *hcList ) ridgeCylinders = cmds.polyUnite( *rcyList ) ridgeCubes = cmds.polyUnite( *rcuList ) else: holeCylinders = hcList[0] ridgeCylinders = rcyList[0] ridgeCubes = rcuList[0] block = cmds.polyCBoolOp( block, holeCylinders, op=2 ) ridgeCutter = cmds.polyCBoolOp( ridgeCylinders, ridgeCubes, op=2 ) block = cmds.polyCBoolOp( block, ridgeCutter, op=2 ) return block
def combine_separate(): """ Depending on selection will combine or separate objects. Script will try to retain the transforms and outline position of the first object selected. """ def clean_up_object(new): """ Cleans up after `polyUnite` / `polySeparate` """ if not new.get_parent() == parent: new.set_parent(parent) cmds.reorder(str(new), f=True) cmds.reorder(str(new), r=outliner_index) new.transform.set_pivot(pivot) new.attr['rotate'] = list(transforms.rotate) new.attr['scale'] = list(transforms.scale) return cmds.rename(str(new), name.split('|')[-1]) selected = mampy.daglist(os=True, tr=True, l=True) if not selected: raise InvalidSelection() dag = selected.pop() name, parent = dag.short_name, dag.get_parent() transforms = dag.transform.get_transforms() pivot = dag.transform.get_rotate_pivot() if selected: logger.debug('Combining Objects.') for each in selected: if dag.is_child_of(each): raise InvalidSelection('Cannot parent an object to one of its ' 'children') elif dag.is_parent_of(each): continue each.set_parent(each) outliner_index = get_outliner_index(dag) dag.transform.attr['rotate'] = (0, 0, 0) dag.transform.attr['scale'] = (1, 1, 1) if selected: new_dag = Node(cmds.polyUnite(name, selected.cmdslist(), ch=False)[0]) cmds.select(clean_up_object(new_dag), r=True) else: logger.debug('Separate Objects.') new_dags = mampy.daglist(cmds.polySeparate(name, ch=False)) for new in new_dags: cmds.rename(clean_up_object(new), name.split('|')[-1]) cmds.delete(name) cmds.select(new_dags.cmdslist(), r=True)
def tieOff(): global balloonRadius, balloonQuantity knotVals = mc.pointPosition('balloonTemp.vtx[96]', w=True) knotThickness = balloonRadius * .05 endHeight = balloonRadius * .15 knotRadius = knotVals[0] knotPos = ( knotVals[1] - (.5 * knotThickness)) mc.polyCylinder( n="knotTemp", r=knotRadius, h=knotThickness, sx=12, sy=3, sz=0, rcp=0, cuv=3) mc.delete( 'knotTemp.f[36:37]') mc.setAttr( 'knotTemp.translateY', knotPos ) mc.scale(1.25, 1.75, 1.25, 'knotTemp.vtx[12:35]', r=True ) mc.lattice( n='knot', cp=True, dv =(2, 2, 2), objectCentered=True, ldv=(2,2,2)) mc.move( (.75 * knotThickness), 'knotLattice.pt[1][0][0:1]', r=True, y=True) mc.move( (.25 * knotThickness), 'knotLattice.pt[0][0][0:1]', r=True, y=True) mc.duplicate('knotTemp') mc.rotate(180, 'knotTemp1', z=True) mc.polyCone( n="endTemp", r=knotRadius*2, h=endHeight, sx=12, sy=6, sz=3, rcp=0, cuv=3) mc.delete( 'endTemp.f[60:83]', 'endTemp.f[96:107]') mc.setAttr( 'endTemp.translateY', knotPos - knotThickness/2 ) mc.scale( 1.15, 1, 1.15, 'endTemp.vtx[36:59]') mc.move((.5 * endHeight), 'endTemp.vtx[0:11]', 'endTemp.vtx[72]', y=True, r=True) mc.polyUnite( 'balloonTemp', 'knotTemp', 'knotTemp1', 'endTemp', ch=True ) mc.polySoftEdge( a = 180 ) mc.polyMergeVertex( d=.001) mc.polyEditUV('polySurface1.map[0:126]', pu=0.5, pv=1, su=1, sv=0.575) mc.polyEditUV('polySurface1.map[127:230]', pu=0.5, pv=0.35, su=2, sv=.25) mc.polyEditUV('polySurface1.map[267:318]', u=0, v=-0.1, pu=0.5, pv=0, su=1, sv=.5) mc.polyEditUV('polySurface1.map[231:266]', 'polySurface1.map[319]', u=0, v=-.175, pu=0.5, pv=0.25, su=0.25, sv=0.25) mc.polyMergeUV('polySurface1.map[103:126]', d=0.5, ch=True ) mc.polyEditUV('polySurface1.map[104]', r=False, u=0) mc.polyEditUV('polySurface1.map[103]', r=False, u=1) mc.polySmooth('polySurface1', mth=0, dv=1, c=1, kb=0, ksb=1, khe=0, kt=1, kmb=0, suv=0, peh=0, sl=1, dpe=1, ps=0.1 , ro=1, ch=True) mc.DeleteHistory() mc.delete( 'knotTemp1') mc.rename('polySurface1', 'balloon1') mc.select(cl=True) return