def d(self): # Tool To create the measurement tool when vertexes are selected if self.getType(0) == 'vertex': locators = cmds.ls(type='locator') distances = cmds.ls(type='distanceDimShape') cmds.distanceDimension( startPoint=cmds.pointPosition(self.getSelection()[0]), endPoint=cmds.pointPosition(self.getSelection()[1])) newLocators = set(cmds.ls(type='locator')) - set(locators) newDistances = set( cmds.ls(type='distanceDimShape')) - set(distances) if len(newLocators) == 2: cmds.group(list(newLocators)[0], list(newLocators)[1], list(newDistances)[0], n='measurement') elif len(newLocators) == 1: cmds.group(list(newLocators)[0], list(newDistances)[0], n='measurement') elif self.getType(0) == 'face': cmds.polySubdivideFacet(sbm=1) #starts it off in linear form self.smoothTool() ##elif self.getType(0) == 'mesh': ## self.smoothTool() self.updateToolHUD()
def proxyCylinder_subDiv(proxy_cyl,numV=5,numU=1): ''' Subdivide proxy cylinder mesh. @param proxy_cyl: Proxy cylinder mesh to subdivide @type proxy_cyl: str @param numV: Number of V subdivisions @type numV: int @param numU: Number of U subdivisions @type numU: int ''' mc.polySubdivideFacet(proxy_cyl,duv=numU,dvv=numV,sbm=1,ch=False)
def hexalate(): list = cmds.ls(sl=1, fl=1) for i in range(len(list)): cmds.polyTriangulate(list[i], ch=True) edgeCount = cmds.polyEvaluate(e=1) cmds.select((list[i] + '.e[0:' + str(edgeCount) + ']'), r=True) hexEdgeSet = cmds.sets(name='edgeSetHex') cmds.polySubdivideFacet(list[i], dv=1, m=0, ch=1) cmds.select(hexEdgeSet, r=1) cmds.polyDelEdge(cv=1, ch=1) cmds.select(hexEdgeSet, r=1, ne=1) cmds.delete() cmds.select(list)
def generate(pts): """Takes in a list of tuples (set of 3D points) and generates a polygon model""" cmds.polyCreateFacet(name="shirt", p=points) cmds.polyTriangulate() cmds.polyQuad(angle=90) cmds.polySubdivideFacet(dv=SUBDIVISIONS) cmds.polyTriangulate() # Center shirt on origin centerX = cmds.objectCenter("shirt", x = True, gl = True) centerY = cmds.objectCenter("shirt", y = True, gl = True) centerZ = cmds.objectCenter("shirt", z = True, gl = True) cmds.move(-centerX, -centerY, -centerZ, "shirt", absolute=True)
def generate(pts): """Takes in a list of tuples (set of 3D points) and generates a polygon model""" cmds.polyCreateFacet(name="shirt", p=points) cmds.polyTriangulate() cmds.polyQuad(angle=90) cmds.polySubdivideFacet(dv=SUBDIVISIONS) cmds.polyTriangulate() # Center shirt on origin centerX = cmds.objectCenter("shirt", x=True, gl=True) centerY = cmds.objectCenter("shirt", y=True, gl=True) centerZ = cmds.objectCenter("shirt", z=True, gl=True) cmds.move(-centerX, -centerY, -centerZ, "shirt", absolute=True)
def hexalate(): list=cmds.ls(sl=1,fl=1) for i in range (len(list)): cmds.polyTriangulate(list[i], ch = True) edgeCount = cmds.polyEvaluate( e=1) cmds.select( (list[i] + '.e[0:' + str(edgeCount) + ']'), r=True) hexEdgeSet = cmds.sets(name = 'edgeSetHex') cmds.polySubdivideFacet( list[i], dv = 1, m=0, ch=1) cmds.select(hexEdgeSet, r=1) cmds.polyDelEdge(cv=1, ch=1) cmds.select(hexEdgeSet, r = 1, ne = 1) cmds.delete() cmds.select(list)
def makeWindows(self, name_, windowShaders, booleans): ''' Creates windows for a cylinder or pipe house. self: Object of the class House. name_: A string with the name the polygonal house object will have. windowShader: A list with shaders for the windows. booleans: A boolean variable which determines whether the windows should be combined with the house using boolean difference or not. On exit: Columns of windows are created using makeWindowColumn(...) and these are then duplicated around the house. The windows are assigned shaders using assignWindowShaders(...), and are then combined with the house. The House object's name attribute is updated. ''' windowHeight = random.uniform(0.5,1.9) # Make sure the window height is not too close to 1.6 since the window edge # in that case will be too close to a edge loop on the house and the boolean # operation will fail. if booleans and (windowHeight > 1.59 and windowHeight < 1.61): windowHeight = random.choice([1.59, 1.61]) floorHeight = int(math.ceil(windowHeight)) heightNum = int((self.height - (1 + floorHeight/2.0))/floorHeight) if heightNum == 0: return angleR = 2.0 * math.pi / self.sides angleD = math.degrees(angleR) distance = math.cos(angleR / 2.0) * self.radius sideWidth = 2.0 * self.radius * math.sin(angleR / 2.0) windowWidth = random.uniform((sideWidth -0.2)/ 2.0, sideWidth - 0.2) if windowWidth <= 0.1: return windowColumn = makeWindowColumn(windowWidth, windowHeight, heightNum, floorHeight) cmds.rotate(90 - angleD / 2.0, windowColumn[0], y = True) for j in range(self.sides): # Copy the column faces around the house. cmds.polyChipOff(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]", dup = True, kft = True, translate = (math.sin(math.pi/2.0 - angleR/2.0 + angleR * j) * distance,0,math.cos(math.pi/2.0 - angleR/2.0 + angleR * j) * distance)) cmds.select(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]") cmds.rotate(angleD, y = True) cmds.delete(all = True, ch = True) cmds.refresh() cmds.delete(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]") windowNum = self.sides * heightNum assignWindowShaders(windowColumn, windowNum, windowShaders) cmds.select(windowColumn[0] + ".f[0:" + str(windowNum * 6 - 1) +"]") cmds.polySubdivideFacet() if booleans == True: result = cmds.polyBoolOp(self.name,windowColumn[0], op = 2, n = name_) else: result = cmds.polyUnite(self.name,windowColumn[0], n = name_) self.name = result[0] cmds.delete(all = True, ch = True)
def d (self): # Tool To create the measurement tool when vertexes are selected if self.getType(0) == 'vertex': locators = cmds.ls(type = 'locator') distances = cmds.ls(type = 'distanceDimShape') cmds.distanceDimension(startPoint = cmds.pointPosition( self.getSelection()[0]) ,endPoint= cmds.pointPosition( self.getSelection()[1] )) newLocators = set(cmds.ls(type='locator')) - set(locators) newDistances = set(cmds.ls(type='distanceDimShape')) - set(distances) if len(newLocators) == 2: cmds.group(list(newLocators)[0], list(newLocators)[1] , list(newDistances)[0], n = 'measurement') elif len(newLocators) == 1: cmds.group(list(newLocators)[0], list(newDistances)[0], n = 'measurement') elif self.getType(0) == 'face': cmds.polySubdivideFacet(sbm=1) #starts it off in linear form self.smoothTool() ##elif self.getType(0) == 'mesh': ## self.smoothTool() self.updateToolHUD()
def defaultBuilding(self): defaultSide = cmds.polyPlane(name='default_wall', w=2, h=3, sx=3, sy=1) cmds.rotate(90, 0, 0) cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) cmds.select('default_wall' + '.e[3]') cmds.move(-0.4, 0, 0, r=True) cmds.select('default_wall' + '.e[5]') cmds.move(0.4, 0, 0, relative=True) cmds.select('default_wall' + '.f[2]', 'default_wall' + '.e[0]') cmds.polyExtrudeFacet(keepFacesTogether=True, thickness=0.04) cmds.select('default_wall' + '.f[1]') cmds.polyExtrudeFacet(offset=0.2) cmds.polySubdivideFacet('default_wall' + '.f[1]', duv=1) cmds.select('default_wall' + '.f[1]', 'default_wall' + '.f[15:17]') cmds.polyExtrudeFacet(keepFacesTogether=False, offset=.02) cmds.select('default_wall' + '.f[18:33]') cmds.polyExtrudeFacet(keepFacesTogether=True, thickness=.02) cmds.select('default_wall' + '.f[3]', 'default_wall' + '.f[7:9]', 'default_wall' + '.f[5:6]') cmds.delete() cmds.rename('default_wall', 'Wall')
def generate(pts): """Takes in a list of tuples (set of 3D points) and generates a polygon model""" cmds.polyCreateFacet(name="shirt", p=points) cmds.polyTriangulate() cmds.polySubdivideFacet(dv=SUBDIVISIONS) cmds.polyTriangulate()
a = cmds.polyCube(w=LargeurDeMaison, h=HauteurDeMaison + random.uniform(0, 0.3), d=LongeurDeMaison, n=Maison) cmds.rename('Maison#') ##Pour chaque case subdivise2fois for j in range(len(ListeDsMurs)): cmds.select(ListeDsMurs[j]) list = cmds.ls(sl=True, fl=True) cmds.polySubdivideFacet(dvv=2) ##deselectionne les vertices du bords et fait une liste de points #print(list) for item in list: vtxCount = cmds.polyEvaluate(v=True) #print(vtxCount) cmds.select(cl=True) cmds.select(item + '.vtx[0:' + str(vtxCount) + ']', add=True) #cmds.polySelectConstraint(pp=6) mel.eval('PolySelectTraverse 2') pointsInternes = cmds.ls(selection=True, sn=True, fl=True) ##Bouge chaque point selon un random et place une instance de maison #print(pointsInternes)
def subdiv_mesh(self): if self.meshObj is None: return cmds.polySubdivideFacet(n=self.meshObj[0], dv=1)
cmds.select('Monolith_Top.e[6]', replace=True) cmds.move(0, 0.546549, 0, r=True) cmds.select('Monolith_Top.e[11]', replace=True) cmds.move(0.397275, 0, 0, r=True) cmds.select('Monolith_Top.e[11]', add=True) cmds.select('Monolith_Top.e[2]', replace=True) cmds.select('Monolith_Top.e[1]', tgl=True) cmds.scale(1, 1, 0.867012, pivot=(0, 14.166275, 0), r=True) #Selects inner edge of left slab and moves it cmds.select('Monolith_Left', replace=True) cmds.select('Monolith_Left.e[5]', replace=True) cmds.move(-0.47427, 0, 0, r=True) #Selects all the objects created cmds.select('Monolith_Right', 'Monolith_Left', 'Monolith_Top', replace=True) #Add Division Command cmds.polySubdivideFacet("Monolith_Right", ch=True, divisions=1, mode=0) cmds.polySubdivideFacet("Monolith_Left", ch=True, divisions=1, mode=0) cmds.polySubdivideFacet("Monolith_Top", ch=True, divisions=1, mode=0) #Extruding a particular face, moving it, scaling it, and relatively moving it again cmds.select('Monolith_Right.f[0]', replace=True) cmds.hilite('Monolith_Right.f[0]') cmds.selectMode(component=True) cmds.select('Monolith_Right.f[0]', replace=True) cmds.polyExtrudeFacet('Monolith_Right.f[0]', pivotX=3.95256825, pivotY=2.5335, pivotZ=1.918422108, divisions=1, smoothingAngle=30) cmds.setAttr("polyExtrudeFace1.localTranslate", 0, 0, 0.808428, type="double3") cmds.scale(0.899733,
def addDivision( evt=0 ): if not cmds.ls( sl=1 ): return None mel.eval( "SGMPlugMod01Command -upm" ) cmds.polySubdivideFacet( dv=1, m=0, ch=1 ) mel.eval( "SGMPlugMod01Command -upm" )
def makeWindows(self, name_, windowShaders, booleans): ''' Creates windows for a box house. self: Object of the class BoxHouse. name_: A string with the name the house will have. windowShader: A list with shaders for the windows. booleans: A boolean variable which determines whether the windows should be combined with the house using boolean difference or not. On exit: Columns of windows are created using makeWindowColumn(...) and these are then duplicated around the house. The windows are assigned shaders using assignWindowShaders(...), and are then combined with the house. The House object's name attribute is updated. ''' windowHeight = random.uniform(0.5,1.9) # Make sure the window height is not too close to 1.6 since the window edge # in that case will be too close to a edge loop on the house and the boolean # operation will fail. if booleans and (windowHeight > 1.59 and windowHeight < 1.61): windowHeight = random.choice([1.59, 1.61]) windowWidth = random.uniform(1, 3) floorHeight = int(math.ceil(windowHeight)) heightNum = max(0,int((self.height - (1 + floorHeight/2.0))/floorHeight)) if heightNum == 0: return widthNum = max(0,int((self.width - 0.3) / (windowWidth))) if (widthNum != 0): # Makes it possible for houses to have less windows or no windows on a side. widthNum = widthNum - random.randint(0, min(2, widthNum)) # Space between window columns along the width of the house. widthSpace = (self.width - (widthNum * windowWidth)) /(widthNum + 1) depthNum = max(0,int((self.depth - 0.3)/ windowWidth)) if (depthNum != 0): # Makes it possible for houses to have less windows or no windows on a side. depthNum = depthNum - random.randint(0, min(2, depthNum)) if (depthNum == 0) and (widthNum == 0): return # Space between window columns along the width of the house. depthSpace = (self.depth - (depthNum * windowWidth)) / (depthNum + 1) windowColumn = makeWindowColumn(windowWidth,windowHeight, heightNum, floorHeight) for j in range(widthNum): # Duplicates all the faces of the first window column and translates the duplicates along the width. cmds.polyChipOff(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]", dup = True, kft = True, translate = (-self.width/2.0 + windowWidth/2.0 + widthSpace + (windowWidth + widthSpace) * j, 0, self.depth/2.0)) cmds.polyChipOff(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]", dup = True, kft = True, translate = (-self.width/2.0 + windowWidth/2.0 + widthSpace + (windowWidth + widthSpace) * j, 0, -self.depth/2.0)) cmds.delete(all = True, ch = True) cmds.refresh() cmds.select(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]") cmds.rotate(90, y = True) for j in range(depthNum): # Duplicates all the faces of the first window column and translates the duplicates along the depth. cmds.polyChipOff(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]", dup = True, kft = True, translate = (self.width/2.0, 0, -self.depth/2.0 + windowWidth/2.0 + depthSpace + (windowWidth + depthSpace) * j), ws = True) cmds.polyChipOff(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]", dup = True, kft = True, translate = (-self.width/2.0, 0, -self.depth/2.0 + windowWidth/2.0 + depthSpace + (windowWidth + depthSpace) * j), ws = True) cmds.delete(all = True, ch = True) cmds.refresh() cmds.select(windowColumn[0] + ".f[0:" + str((heightNum * 6) - 1) + "]") cmds.delete() windowNum = widthNum * heightNum * 2 + depthNum * heightNum * 2 # Total number of windows. assignWindowShaders(windowColumn, windowNum, windowShaders) cmds.select(windowColumn[0] + ".f[0:" + str(windowNum * 6 - 1) +"]") cmds.polySubdivideFacet() if booleans: result = cmds.polyBoolOp(self.name,windowColumn[0], op = 2, n = name_) else: result = cmds.polyUnite(self.name,windowColumn[0], n = name_) self.name = result[0] cmds.delete(self.name, ch = True)
def addDivision(evt=0): if not cmds.ls(sl=1): return None mel.eval("SGMPlugMod01Command -upm") cmds.polySubdivideFacet(dv=1, m=0, ch=1) mel.eval("SGMPlugMod01Command -upm")