def createHoneyPiece(n): planeName = 'plane'+str(n) print planeName cmds.polyPlane(w=20, h=20, sx=12, sy=12, n=planeName) edgeNum = 26 modVal = 1; edgeArray = [] for i in range(52): edgeArray.append(planeName+'.e['+str(edgeNum)+']'); edgeNum += 2 if(edgeNum == 51): edgeNum = 101 if(edgeNum==50): edgeNum = 49 if(edgeNum == 126): edgeNum = 176 if(edgeNum==125): edgeNum = 124 if(edgeNum==201): edgeNum = 251 if(edgeNum==200): edgeNum = 199 if(edgeNum==275): edgeNum = 274 cmds.polyBevel(edgeArray, offset=1,offsetAsFraction=1,autoFit=1,segments=1,worldSpace=1,uvAssignment=0,fillNgons=1,mergeVertices=1,mergeVertexTolerance=0.0001,smoothingAngle=30,miteringAngle=180,angleTolerance=180,ch=1) cmds.select( clear=True) print len(edgeArray) del edgeArray[:] print len(edgeArray) for i in range(532, 620): cmds.select(planeName+'.e['+str(i)+']', toggle=True); size = 36; edgeNum = 31 counter = 0 for i in range(size): cmds.select(planeName+'.e['+str(edgeNum)+']', toggle=True); edgeNum += 2 counter += 1 if(counter == 12): counter = 0 edgeNum += 7; cmds.delete(); for i in range(12): cmds.select(planeName+'.f['+str(i)+']', toggle=True); for i in range(96, 108): cmds.select(planeName+'.f['+str(i)+']', toggle=True); for i in range(1,8): cmds.select(planeName+'.f['+str(i*12)+']', toggle=True); for i in range(1,8): cmds.select(planeName+'.f['+str(i*12+11)+']', toggle=True); cmds.delete(); cmds.scale(1, 1, 0.5, planeName); #cmds.select(planeName+'.f[0:113]') cmds.polyExtrudeFacet(planeName+'.f[0:113]', constructionHistory=1, keepFacesTogether=0, pvx=4.7, pvy=-1.058, pvz=2.38, divisions=1, twist=0, taper=1, off=0, thickness=0, smoothingAngle=30) cmds.setAttr("polyExtrudeFace"+str(n*2+1)+".localScale", 0.833333, 0.833333, 0.829938, type="double3") cmds.delete(); cmds.select(planeName+'.f[0:723]') cmds.polyExtrudeFacet(constructionHistory=1, keepFacesTogether=1, pvx=-4.7, pvy=-1.058, pvz=2.38, divisions=1, twist=0, taper=1, off=0, thickness=0, smoothingAngle=30) cmds.setAttr("polyExtrudeFace"+str(n*2+2)+".localTranslate", 0, 0, 1, type="double3")
def connector(): connectorLength = cmds.intSliderGrp('connectorLength', q=True, v=True) connectorSizeX = (1 * 0.8) - 0.1 connectorSizeY = (1 * 0.8) - 0.1 connectorSizeZ = (connectorLength * 0.4) rgb = cmds.colorSliderGrp('blockColour', q=True, rgbValue=True) connector = cmds.polyCylinder(r=(connectorSizeX/2.0),h=connectorSizeZ, sh=6) cmds.rotate(90,rotateX=True) cmds.move((connectorSizeY/2.0), moveY=True, a=True) connectorName = cmds.ls(connector)[0] cmds.select(connectorName+".e[40:99]") cmds.scale(0.8, 0.8, 0.8, relative=True) cmds.select(connectorName+".e[40:59]") cmds.move(-0.13, moveZ=True,r=True) cmds.select(connectorName+".e[80:99]") cmds.move(0.13, moveZ=True,r=True) axelShape = cmds.polyCube(h = 0.19, w=(connectorSizeZ+0.2), d=0.19) cmds.move((connectorSizeY/2.0), moveY=True, a=True) axelName = cmds.ls(axelShape)[0] cmds.select(axelName+".f[0]") cmds.select(axelName+".f[1]", add=True) cmds.select(axelName+".f[2]", add=True) cmds.select(axelName+".f[3]", add=True) cmds.polyExtrudeFacet(lt=(0,0,0.15), kft=False) cmds.select(axelShape) cmds.polyBevel(sg=2, oaf=True, fn=True) cmds.rotate(90, rotateY=True) if(connectorLength == 2): cmds.select(connectorName+".e[242]") cmds.select(connectorName+".e[246]", add=True) cmds.move(-0.05, moveY=True, relative=True) cmds.select(connectorName+".e[252]") cmds.select(connectorName+".e[256]", add=True) cmds.move(0.05, moveY=True, relative=True) cmds.select(connector) cmds.select(axelShape, add=True) connector = cmds.polyCBoolOp(op=2, ch=False, n="Connector" + str(rnd.randint(1000,9999))) applyMaterial(connector, rgb) cmds.delete(ch=True)
def bevelEdge(evt=0): mel.eval("SGMPlugMod01Command -upm") cmds.polyBevel(f=0.5, oaf=1, af=1, sg=1, ws=1, sa=30, fn=1, mv=0, ma=180, at=180) mel.eval("SGMPlugMod01Command -upm") cmds.select(cl=1)
def createHoneyPiece(n): planeName = 'plane'+str(n) cmds.polyPlane(w=20, h=20, sx=12, sy=12, n=planeName) edgeNum = 26 modVal = 1; edgeArray = [] for i in range(52): edgeArray.append(planeName+'.e['+str(edgeNum)+']'); edgeNum += 2 if(edgeNum == 51): edgeNum = 101 if(edgeNum==50): edgeNum = 49 if(edgeNum == 126): edgeNum = 176 if(edgeNum==125): edgeNum = 124 if(edgeNum==201): edgeNum = 251 if(edgeNum==200): edgeNum = 199 if(edgeNum==275): edgeNum = 274 cmds.polyBevel(edgeArray, offset=1,offsetAsFraction=1,autoFit=1,segments=1,worldSpace=1,uvAssignment=0,fillNgons=1,mergeVertices=1,mergeVertexTolerance=0.0001,smoothingAngle=30,miteringAngle=180,angleTolerance=180,ch=1) cmds.select( clear=True) del edgeArray[:] for i in range(532, 620): cmds.select(planeName+'.e['+str(i)+']', toggle=True); size = 36; edgeNum = 31 counter = 0 for i in range(size): cmds.select(planeName+'.e['+str(edgeNum)+']', toggle=True); edgeNum += 2 counter += 1 if(counter == 12): counter = 0 edgeNum += 7; cmds.delete(); for i in range(12): cmds.select(planeName+'.f['+str(i)+']', toggle=True); for i in range(96, 108): cmds.select(planeName+'.f['+str(i)+']', toggle=True); for i in range(1,8): cmds.select(planeName+'.f['+str(i*12)+']', toggle=True); for i in range(1,8): cmds.select(planeName+'.f['+str(i*12+11)+']', toggle=True); cmds.delete(); cmds.select(planeName);
def createBeveledCube(self): name = 'bc' + str(self.num_bc) cmds.polyCube(n=name, sx=1, sy=1, sz=1, h=1, w=1, d=1) cmds.polyBevel(name + '.e[0]', name + '.e[1]', name + '.e[2]', name + '.e[3]', segments=4, fraction=0.5, offsetAsFraction=1) cmds.delete(name + '.e[9]', name + '.e[5]', name + '.e[13]', name + '.e[1]', name + '.e[7]', name + '.e[11]', name + '.e[15]', name + '.e[3]') self.num_bc += 1 return name
def bevelTool(self): X = self.getSelection( ) # this is added because once the bevel is performed the face is deselected. cmds.polyBevel(X, ch=1, offset=0.05, segments=1, smoothingAngle=30, offsetAsFraction=1, autoFit=1, worldSpace=1, angleTolerance=180, miteringAngle=180, uvAssignment=0, mergeVertices=1, mergeVertexTolerance=0.0001) self.setAttributes(attrs=[('Offset', '.offset'), ('Segments', '.segments')]) self.Dragger(X, 'Bevel')
def skinBrowSurfaceMap(self): """ skin joints to surface map """ if not cmds.objExists(self.browMapGeo): print "create browMapSurf first!!" else : browMapSurf = self.browMapGeo browJnts = cmds.ls ("*" + self.browP + "*", type ="joint") x, y, z, orderJnts = self.orderJnts(browJnts) jntNum = len(orderJnts) orderChildren = cmds.listRelatives(orderJnts, c =1, type = "joint") edges= cmds.polyEvaluate(browMapSurf, e =1 ) cmds.polyBevel(browMapSurf +'.e[0:%s]'%(edges-1), offset=0.01) cmds.delete(browMapSurf, constructionHistory =1) faces = [] for i in range(0, jntNum): face = browMapSurf+ ".f[%s]"% str(i) faces.append(face) faces.sort() faceLen = len(faces) cmds.select(cl=1) #get the joints to be bound, check if "headSkel_jnt" exists if not cmds.objExists(self.headSkelJnt): headSkelPos = cmds.xform('headSkelPos', q =1, ws =1, t =1 ) cmds.joint(n = self.headSkelJnt , p = headSkelPos ) orderChildren.append(self.headSkelJnt ) skinCls = cmds.skinCluster(orderChildren , browMapSurf, toSelectedBones=1 ) # 100% skinWeight to headSkel_jnt cmds.skinPercent(skinCls[0], browMapSurf, transformValue = [self.headSkelJnt , 1]) # skinWeight for i in range (0, jntNum): vtxs = cmds.polyListComponentConversion(faces[i], ff=True, tv=True ) #cmds.select(vtxs, r=1) print faces[i], orderChildren[i] cmds.skinPercent( skinCls[0], vtxs, transformValue = [ orderChildren[i], 1])
def honeycomb(xbound, zbound, flat, buildCity): dx = 0 indentOn = False #start 0.867 ahead cellnum = 0 while (dx < xbound): dz = 0 if(indentOn): dz = 0.867 while (dz < zbound): cellname = "cell" + "%04d"%cellnum randomheight = 0 raiseMe = False if not flat: randomheight = .1 - (0.2 * random.random()) if buildCity: if xbound/2 - xbound/10 < dx and dx < xbound/2 + xbound/10 and zbound/2 - zbound/10 < dz and dz < zbound/2 + zbound/10: raiseMe = True randombuildingheight = 20 - (10 * random.random()) cmds.polyCylinder(name = cellname, ax=[0,1,0], radius=1, height=1, sx=6, sy=1, sz=0) if raiseMe: cmds.move(0, randombuildingheight, 0, cellname+'.f[7]', r=True) else: cmds.move(0, randomheight, 0, cellname+'.f[7]', r=True) cmds.polyExtrudeFacet(cellname+'.f[7]', kft=False, s=(0.896415,0.896415,0.896415), divisions = 3) cmds.polyExtrudeFacet(cellname+'.f[7]', kft=False, ty=-0.15636, divisions=3) cmds.select(cellname) cmds.polyBevel(offset = 0.7, offsetAsFraction = 1, autoFit = 1, segments = 1, worldSpace = 1, uvAssignment = 0, fillNgons = 1, mergeVertices = 1, mergeVertexTolerance = 0.0001, miteringAngle = 180, angleTolerance = 180, ch = 1) cmds.move(dx, 0, dz) print "cylinder " + cellname + " location = dx: " + str(dx) + ", dz: " + str(dz) dz+=1.729 cellnum += 1 dx += 1.5 indentOn = not indentOn cmds.select([node for node in cmds.ls() if 'cell' in node and 'Shape' not in node]) cmds.group(name='honeycomb') cmds.move(-xbound/2, 0, -zbound/2, 'honeycomb')
def pagoda(numStory): for i in range(0,numStory): #build a level of the pagoda cmds.polyCube(name='pagoda_story' + str(i), d=5, h=3, w=5) cmds.move(0,i*3, 0) if i == numStory-1: cmds.polyPyramid(name='pagoda_finalRoof', w=6) cmds.move(0,2.5+3*i,0) cmds.rotate(0,45,0) cmds.scale(1.15,0.655,1.15) cmds.polyBevel() cmds.select('pagoda_finalRoof.f[5]', 'pagoda_finalRoof.f[8]', 'pagoda_finalRoof.f[10]', 'pagoda_finalRoof.f[12]', 'pagoda_finalRoof.f[17]') cmds.polyExtrudeFacet(kft=True, translateY=.1607) cmds.select('pagoda_finalRoof.f[18]', 'pagoda_finalRoof.f[21]', 'pagoda_finalRoof.f[24]', 'pagoda_finalRoof.f[27]') cmds.polyExtrudeFacet(kft=True, localTranslateZ=0.65, translateY=0.3) cmds.polyExtrudeFacet(kft=True, localScale=(0.7, 0.8, 1)) cmds.polyExtrudeFacet(kft=True, localTranslateZ=0.43) cmds.select('pagoda_finalRoof.f[17]') cmds.polyExtrudeFacet(kft=True, translateY = numStory, divisions=12) #cmds.select('pagoda_finalRoof.f[0]', 'pagoda_finalRoof.f[2]', 'pagoda_finalRoof.f[3]', 'pagoda_finalRoof.f[4]') else: n='pagoda_roof' + str(i) cmds.polyCube(name=n, d=7, h=1, w=7) cmds.move(0,1.5 + 3*i,0) #faces 0,2,4,5 cmds.select(n+'.f[0]', n+'.f[2]', n+'.f[4:5]') cmds.polyExtrudeFacet(kft=True, localScaleY = 0.397, localTranslateZ=0.873108) cmds.move(0, -.204, 0, r=True) cmds.polyExtrudeFacet(kft=True, localScaleY = 0.397, localTranslateZ = 0.9) cmds.move(0, -.4, 0, r=True) cmds.select(n) #cmds.polyBevel() #cmds.select([n+'.f[27]', n+'.f[30]', n+'.f[32]', n+'.f[34]', n+'.f[43]', n+'.f[46]', n+'.f[48]', n+'.f[50]', n+'.f[56]', n+'.f[58]', n+'.f[63:64]', n+'.f[76:79]', n+'.f[84:87]']) #cmds.polyExtrudeFacet(kft=True, translateY=.12) cmds.select([node for node in cmds.ls() if 'pagoda' in node and 'Shape' not in node]) cmds.group(name='pagoda_' + str(numStory) + 'stories')
def bevelEdges(*args): """select obj, this will randomly bevel some edges""" cutoffRaw = cmds.intSliderGrp(widgets["bpercISG"], q=True, v=True) cutoff = cutoffRaw / 100.0 sel = cmds.ls(sl=True) for obj in sel: edges = cmds.ls("%s.e[*]" % obj, fl=True) bevelList = [] for edge in edges: rand = random.uniform(0, 1) if rand <= cutoff: bevelList.append(edge) cmds.select(cl=True) cmds.select(bevelList, r=True) cmds.polyBevel(fraction=.5, offset=.05) cmds.select(sel, r=True)
def table(): tablewidthz = cmds.intSliderGrp(slider1, q=True, value=True) tableWidthx = cmds.intSliderGrp(slider2, q=True, value=True) tableHeight = cmds.intSliderGrp(slider3, q=True, value=True) #Roundness = cmds.intSliderGrp(slider4, q=True, value=True) #mesa table = cmds.polyCube(h=0.7, w=tableWidthx, depth=tablewidthz) rtable = cmds.ls(table[0]) print(rtable) cmds.move(0,tableHeight/2.0-0.3,0) cmds.select(str(rtable[0])+'.e[4:5]') cmds.select(str(rtable[0])+'.e[8:9]', add=True) # cmds.select('table.e[4:5]') # cmds.select('table.e[8:9]', add=True) cmds.polyBevel3(offset=1, segments=3) cmds.polyBevel3(rtable[0], offset=0.1) #patas pataUno = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(-tableWidthx/2.0 + 1,0,tablewidthz/2.0 - 1) cmds.polyBevel(offset=0.1) pataDos = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(tableWidthx/2.0 - 1,0,tablewidthz/2.0 - 1) cmds.polyBevel(offset=0.1) pataTres = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(tableWidthx/2.0 - 1,0,-tablewidthz/2.0 + 1) cmds.polyBevel(offset=0.1) pataCuatro = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(-tableWidthx/2.0 + 1,0,-tablewidthz/2.0 + 1) cmds.polyBevel(offset=0.1) mir = random.randint(0, 19) crazyR = random.randint(0,1000) rName = 'Table'+ str(mir) + str(crazyR) cmds.group(table,pataUno, pataDos, pataTres, pataCuatro, n=rName)
def table(): tablewidthz = cmds.intSliderGrp(slider1, q=True, value=True) tableWidthx = cmds.intSliderGrp(slider2, q=True, value=True) tableHeight = cmds.intSliderGrp(slider3, q=True, value=True) #Roundness = cmds.intSliderGrp(slider4, q=True, value=True) #mesa cmds.polyCube(h=0.7, w=tableWidthx, depth=tablewidthz, n='table') cmds.move(0, tableHeight / 2.0 - 0.3, 0) cmds.select('table.e[4:5]') cmds.select('table.e[8:9]', add=True) cmds.polyBevel3(offset=1, segments=3) cmds.polyBevel3('table', offset=0.1) #patas i = 1 cmds.polyCube(h=tableHeight, w=1, depth=1, n='p_table1_') cmds.move(-tableWidthx / 2.0 + 1, 0, tablewidthz / 2.0 - 1) cmds.polyBevel(offset=0.1) cmds.polyCube(h=tableHeight, w=1, depth=1, n='p_table2_') cmds.move(tableWidthx / 2.0 - 1, 0, tablewidthz / 2.0 - 1) cmds.polyBevel(offset=0.1) cmds.polyCube(h=tableHeight, w=1, depth=1, n='p_table3_') cmds.move(tableWidthx / 2.0 - 1, 0, -tablewidthz / 2.0 + 1) cmds.polyBevel(offset=0.1) cmds.polyCube(h=tableHeight, w=1, depth=1, n='p_table4_') cmds.move(-tableWidthx / 2.0 + 1, 0, -tablewidthz / 2.0 + 1) cmds.polyBevel(offset=0.1) cmds.group('table', 'p_table1_', 'p_table2_', 'p_table3_', 'p_table4_', n='Table1_' + str(i))
def comode(): Counter_H = cmds.intSliderGrp(slider1, q=True, value=True) Counter_W = cmds.intSliderGrp(slider2, q=True, value=True) Counter_d = cmds.intSliderGrp(slider3, q=True, value=True) #Var Counter_support spt_Counter = 0.5 spt_Counter_W = Counter_W - 1.0 spt_Counter_d = Counter_d - 1.0 offset = 0.5 #Var Tirroire seperation = 3 # nbr_Tiroire = 3 nbr_Tiroire = cmds.intSliderGrp(slider4, q=True, value=True) H_tirroire = 1.0 W_Tirroire = Counter_W - 2.0 D_Tirroire = 1.0 #var handle H_Handle = 0.2 w_Handle = 0.5 D_Handle = 0.2 H_topCounter = 1.0 #top counter CounterS = cmds.polyCube(h=spt_Counter, w=spt_Counter_W, d=spt_Counter_d) cmds.polyBevel(CounterS, segments=2, offset=0.01) cmds.move((Counter_W / 2.0 % offset), offset, (Counter_d / 2.0 % offset)) #counter Counter = cmds.polyCube(h=Counter_H, w=Counter_W, d=Counter_d) cmds.polyBevel(Counter, segments=2, offset=0.01) cmds.move(0, (spt_Counter / 2.0 + offset) + (Counter_H / 2.0), 0) #top counter TopCounter = cmds.polyCube(h=H_topCounter / 2, w=Counter_W, d=spt_Counter_d + 1.5) cmds.polyBevel(TopCounter, segments=2, offset=0.01) cmds.move((Counter_W / 2.0 % offset), (Counter_H) + (H_topCounter), (Counter_d / 2.0 % offset)) #group: mir = random.randint(0, 19) crazyR = random.randint(0, 1000) gName = 'Comode' + str(mir) + str(crazyR) cmds.group(CounterS, Counter, TopCounter, n=gName) #Tiroire <=======================================La zone des loops for t in range(nbr_Tiroire): Tirroire = cmds.polyCube(h=H_tirroire, w=W_Tirroire, d=D_Tirroire) cmds.polyBevel(offset=0.01) cmds.move((W_Tirroire / Counter_W - offset), (seperation / 2.0 * (t) + H_tirroire + offset * 2), (Counter_d / 2.0 - 0.3)) cmds.parent(Tirroire, gName, relative=True ) #<=============================solution temporaire ? #Handle for f in range(nbr_Tiroire): Handle = cmds.polyCube(h=H_Handle, w=w_Handle, d=D_Handle) cmds.polyBevel(offset=0.01) cmds.move((W_Tirroire / Counter_W - offset), (seperation / 2.0 * (f) + H_tirroire + offset * 2), (Counter_d / 2.0 - 0.3 + offset)) cmds.parent(Handle, gName, relative=True ) #<=============================solution temporaire ?
def axel(): axelHeight = 1 axelWidth = 1 axelLength = cmds.intSliderGrp('axelLength', q=True, v=True) rgb = cmds.colorSliderGrp('blockColour', q=True, rgbValue=True) axelRadius = 0.48 #0.18 base middle, then extrusions 0.15 each side, slightly smaller than axelSizeX = axelWidth * 0.8 axelSizeY = axelHeight * 0.32 axelSizeZ = axelLength * 0.8 if(axelLength == 2): axel = cmds.polyCube(h = 0.18, w=axelSizeZ, d=0.18) cmds.move((axelRadius/2.0), moveY=True, a=True) axelName = cmds.ls(axel)[0] cmds.select(axelName+".f[0]") cmds.select(axelName+".f[1]", add=True) cmds.select(axelName+".f[2]", add=True) cmds.select(axelName+".f[3]", add=True) cmds.polyExtrudeFacet(lt=(0,0,0.15), kft=False) cmds.select(axel) cmds.polyBevel(sg=2, oaf=True, fn=True) cmds.rotate(90, rotateY=True) #booleans for grooves groove1 = cmds.polyPipe(r=0.25, h=0.25,thickness=0.06) groove2 = cmds.polyPipe(r=0.25, h=0.25,thickness=0.06) cmds.select(groove1) cmds.select(groove2,add=True) cmds.rotate(90,rotateX=True) cmds.move((axelRadius/2.0), moveY=True) cmds.select(groove1) cmds.move(((axelSizeZ/2.0)-0.3), moveZ=True, r=True) cmds.select(groove2) cmds.move(((-axelSizeZ/2.0)+0.3), moveZ=True, r=True) cmds.select(axel) cmds.select(groove1, add=True) cmds.select(groove2, add=True) axel = cmds.polyCBoolOp(op=2, ch=True, n="Axel" + str(rnd.randint(1000,9999))) if(axelLength > 2): axel = cmds.polyCube(h = 0.19, w=axelSizeZ, d=0.19, n="Axel" + str(rnd.randint(1000,9999))) cmds.move((axelSizeY/2.0), moveY=True, a=True) axelName = cmds.ls(axel)[0] cmds.select(axelName+".f[0]") cmds.select(axelName+".f[1]", add=True) cmds.select(axelName+".f[2]", add=True) cmds.select(axelName+".f[3]", add=True) cmds.polyExtrudeFacet(lt=(0,0,0.15), kft=False) cmds.select(axel) cmds.polyBevel(sg=2, oaf=True, fn=True) cmds.rotate(90, rotateY=True) applyMaterial(axel, rgb) cmds.delete(ch=True)
def chair(): Chaisewidthz = cmds.intSliderGrp(slider4, q=True, value=True) ChaiseWidthx = cmds.intSliderGrp(slider5, q=True, value=True) ChaiseHeight = cmds.intSliderGrp(slider6, q=True, value=True) Distance = cmds.intSliderGrp(slider7, q=True, value=True) #silla mainC = cmds.polyCube(h=1, w=ChaiseWidthx, depth=Chaisewidthz) cmds.move(0, ChaiseHeight / 2.0 - 0.3, 0) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) #patas pataUno = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, -4) cmds.polyBevel(offset=0.1) pataDos = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, 4) cmds.polyBevel(offset=0.1) pataTres = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, 4) cmds.polyBevel(offset=0.1) pataCuatro = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, -4) cmds.polyBevel(offset=0.1) #espaldar e_uno = cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5) cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, Chaisewidthz / 2.0 - 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) e_dos = cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5) cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, -Chaisewidthz / 2.0 + 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) e_tres = cmds.polyCube(h=2.5, w=1, depth=Chaisewidthz) cmds.move(-ChaiseWidthx / 2.0 + 0.5, ChaiseHeight * 1.4, 0) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) mir = random.randint(0, 19) crazyR = random.randint(0, 1000) rName = 'Chair' + str(mir) + str(crazyR) cmds.group(mainC, pataUno, pataDos, pataTres, pataCuatro, e_uno, e_dos, e_tres, n=rName)
def bvl(*args): off = cmds.floatField("bevelOff", q=True, v=True) cmds.polyBevel(o=off, oaf=1, at=1, ws=1)
def Chaise(): Chaisewidthz = cmds.intSliderGrp(slider4, q=True, value=True) ChaiseWidthx = cmds.intSliderGrp(slider5, q=True, value=True) ChaiseHeight = cmds.intSliderGrp(slider6, q=True, value=True) Distance = cmds.intSliderGrp(slider7, q=True, value=True) #mesa cmds.polyCube(h=1, w=ChaiseWidthx, depth=Chaisewidthz, n='Chaise') cmds.move(0, ChaiseHeight / 2.0 - 0.3, 0) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) #patas cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata1') cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, -4) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata2') cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, 4) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata3') cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, 4) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata4') cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, -4) cmds.polyBevel(offset=0.1) #espaldar cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5, n='Espaldar_1') cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, Chaisewidthz / 2.0 - 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5, n='Espaldar_2') cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, -Chaisewidthz / 2.0 + 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) cmds.polyCube(h=2.5, w=1, depth=Chaisewidthz, n='Espaldar_3') cmds.move(-ChaiseWidthx / 2.0 + 0.5, ChaiseHeight * 1.4, 0) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) cmds.group('Chaise', 'pata1', 'pata2', 'pata3', 'pata4', 'Espaldar_1', 'Espaldar_2', 'Espaldar_3', n='Chaise1') cmds.select('Chaise1') cmds.move(Distance, -1, 0) cmds.duplicate('Chaise1') cmds.move(-Distance, -1, 0) cmds.rotate(0, -180, 0) cmds.select('Chaise1') cmds.duplicate('Chaise1') cmds.move(0, -1, -Distance) cmds.rotate(0, 90, 0) cmds.select('Chaise1') cmds.duplicate('Chaise1') cmds.move(0, -1, Distance) cmds.rotate(0, -90, 0)
import maya.cmds as cmds import random """select obj, this will randomly bevel some edges""" sel = cmds.ls(sl=True)[0] edges = cmds.ls("%s.e[*]"%sel, fl=True) bevelList = [] for edge in edges: rand = random.uniform(0,1 ) if rand > 0.6: bevelList.append(edge) cmds.select(cl=True) cmds.select(bevelList, r=True) cmds.polyBevel(fraction = .5, offset = .05)
def createLego(x, y, z, name, dimension, victime): g = cmds.radioButtonGrp("color", query=True, sl=True) #xlego=cmds.intSliderGrp('lLego', query=True, value=True) #zlego=cmds.intSliderGrp('loLego', query=True, value=True) #lego de base #Base cmds.polyCube(name="base", w=dimension, d=dimension, h=dimension) cmds.polyExtrudeFacet('base.f[3]', lsx=0.9, lsy=0.9, kft=True) cmds.polyExtrudeFacet('base.f[3]', ltz=-dimension, kft=True) cmds.delete("base.f[3]") if cmds.checkBox("bevel", query=True, value=True): cmds.polyBevel("base.e[0:11]", "base.e[14]", "base.e[16]", "base.e[18]", "base.e[19]", offset=0.02 * dimension) #Cylindre cmds.polyCylinder(n="cercle0", r=0.3 * dimension, h=1.15 * dimension, sx=20) cmds.move(0, 0.1 * dimension, 0, relative=True) cmds.polyExtrudeFacet('cercle0.f[20]', lsx=0.9, lsy=0.9, kft=True) cmds.polyExtrudeFacet('cercle0.f[20]', ltz=-dimension, kft=True) cmds.delete("cercle0.f[20]") if cmds.checkBox("bevel", query=True, value=True): cmds.polyBevel("cercle0.e[20:39]", "cercle0.e[0:19]", "cercle0.e[62:99]", offset=0.02 * dimension) #Longueur, xLego '''for i in range (xlego-1): cmds.duplicate("cercle"+`i`, n="cercle"+`i+1`) cmds.select("cercle"+`i+1`) cmds.move(-2,0,0, relative=True) cmds.group("cercle*", name="cerclesx")''' # Largeur, zlego '''if zlego > 1 : for i in range (0, zlego): cmds.duplicate("cerclesx", n="cerclesz" +` i+1`) cmds.select("cerclesz"+`i+1`) cmds.move(0,0,2*i, relative=True) cmds.group("cerclesx", "cerclesz*", n="cercles") cmds.select("cercles") cmds.move(0,0,-zlego+1, relative=True) else : cmds.rename("cerclesx", "cercles")''' # Fin de creation du LEGO cmds.polyUnite("cercle0", "base", n="lego" + ` name `, ch=False) cmds.move(x, y, z) #Dynamique sur Lego if cmds.checkBox("physics", query=True, value=True) and cmds.checkBox( "animation", query=True, value=True) == False: cmds.rigidBody(n='RigidBodyLego', active=True, b=0.5, sf=0.4) #Shader cmds.shadingNode('blinn', name='legoBlinn' + ` name `, asShader=True) cmds.select("lego" + ` name `) cmds.hyperShade(assign="legoBlinn" + ` name `) cmds.textScrollList('colorblinn', query=True) #Selectionne la victime cmds.select(victime) #Couleur cmds.radioButtonGrp("color", query=True, sl=True) #Random if cmds.radioButtonGrp("color", query=True, sl=True) == 1: randIndClr = random.sample(indiceColor, 1) cmds.setAttr("legoBlinn" + ` name ` + ".color", randIndClr[0][0], randIndClr[0][1], randIndClr[0][2]) #Choice if cmds.radioButtonGrp("color", query=True, sl=True) == 3: colorChoice = cmds.textScrollList("colorblinn", query=True, sii=True) random.shuffle(colorChoice) cmds.setAttr("legoBlinn" + ` name ` + ".color", indiceColor[colorChoice[0] - 1][0], indiceColor[colorChoice[0] - 1][1], indiceColor[colorChoice[0] - 1][2]) if cmds.radioButtonGrp("color", query=True, sl=True) == 2: colorOther = cmds.colorSliderGrp("othrColor", query=True, rgb=True) cmds.setAttr("legoBlinn" + ` name ` + ".color", colorOther[0], colorOther[1], colorOther[2]) #Object if cmds.radioButtonGrp("color", query=True, sl=True) == 4: colorObject = colorClosestVertex(x, y, z) cmds.setAttr("legoBlinn" + ` name ` + ".color", colorObject[0], colorObject[1], colorObject[2])
def bevelEdge( evt=0 ): mel.eval( "SGMPlugMod01Command -upm" ) cmds.polyBevel( f =0.5, oaf=1, af=1, sg=1, ws=1, sa=30, fn=1, mv=0, ma=180, at=180 ) mel.eval( "SGMPlugMod01Command -upm" ) cmds.select( cl= 1 )
def polyBevel(): cmds.polyBevel()
create_joint('waist', c, [0, 1.201, 0]) chest_geo = cmds.polyCube(name='chest_center_geo', w=0.305, h=0.29, d=0.15, sy=2) cmds.move(0, 1.389, 0) cmds.polyMoveEdge('chest_center_geo.e[1]', 'chest_center_geo.e[4]', 'chest_center_geo.e[18:19]', ty=0.12) cmds.polyMoveFacet('chest_center_geo.f[2]', 'chest_center_geo.f[5]', sx=0.6) cmds.polyBevel('chest_center_geo.e[1]', 'chest_center_geo.e[4]', 'chest_center_geo.e[18:19]', o=0.027, sg=2) cmds.polyBevel('chest_center_geo.e[0]', 'chest_center_geo.e[6]', 'chest_center_geo.e[3]', 'chest_center_geo.e[7]', o=0.027, sg=2) waist = BodyPart('waist', c, 'waist_joint_center_crv', ['waist_joint_center_geo', 'chest_center_geo']) waist.defineFather(root) # LEFT ARM # ----------------
def bevelTool(self): X = self.getSelection() # this is added because once the bevel is performed the face is deselected. cmds.polyBevel( X, ch=1, offset=0.05 ,segments =1, smoothingAngle = 30, offsetAsFraction = 1, autoFit = 1, worldSpace = 1, angleTolerance = 180, miteringAngle = 180, uvAssignment = 0, mergeVertices = 1, mergeVertexTolerance = 0.0001 ) self.setAttributes( attrs = [ ('Offset', '.offset'), ('Segments', '.segments') ] ) self.Dragger( X , 'Bevel')
def Chaise(f_Chaisewidthz, f_ChaiseWidthx, f_ChaiseHeight, f_Distance): Chaisewidthz = f_Chaisewidthz ChaiseWidthx = f_ChaiseWidthx ChaiseHeight = f_ChaiseHeight Distance = f_Distance #mesa cmds.polyCube(h=1, w=ChaiseWidthx, depth=Chaisewidthz, n='Chaise') cmds.move(0, ChaiseHeight / 2.0 - 0.3, 0) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) #patas cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata1') cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, -4) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata2') cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, 4) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata3') cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, 4) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7, n='pata4') cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, -4) cmds.polyBevel(offset=0.1) #espaldar cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5, n='Espaldar_1') cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, Chaisewidthz / 2.0 - 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5, n='Espaldar_2') cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, -Chaisewidthz / 2.0 + 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) cmds.polyCube(h=2.5, w=1, depth=Chaisewidthz, n='Espaldar_3') cmds.move(-ChaiseWidthx / 2.0 + 0.5, ChaiseHeight * 1.4, 0) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) cmds.group('Chaise', 'pata1', 'pata2', 'pata3', 'pata4', 'Espaldar_1', 'Espaldar_2', 'Espaldar_3', n='Chaise1') cmds.select('Chaise1') cmds.move(Distance, -1, 0) cmds.duplicate('Chaise1') cmds.move(-Distance, -1, 0) cmds.rotate(0, -180, 0) cmds.select('Chaise1') cmds.duplicate('Chaise1') cmds.move(0, -1, -Distance) cmds.rotate(0, 90, 0) cmds.select('Chaise1') cmds.duplicate('Chaise1') cmds.move(0, -1, Distance) cmds.rotate(0, -90, 0) #def Base(): #Base = cmds.intSliderGrp(slider8, q=True, value=True) #Base #cmds.polyCube(h=1, w=tableWidthx*2, depth=tablewidthz*2, n='Base') #cmds.move(0,-tableHeight/2.0-0.3,0) #cmds.select('Base.e[4:5]') #cmds.select('Base.e[8:9]', add=True) #cmds.polyBevel3(offset=1, segments=3) #cmds.polyBevel3('Base', offset=0.1) # cmds.window(title = 'table') # cmds.columnLayout() # slider1= cmds.intSliderGrp( field=True, label='tablewidthz', minValue=4, maxValue=20, value=10 ) # slider2= cmds.intSliderGrp( field=True, label='tableWidthx', minValue=2, maxValue=20, value=10 ) # slider3= cmds.intSliderGrp( field=True, label='tableHeight', minValue=2, maxValue=20, value=6 ) # slider4= cmds.intSliderGrp( field=True, label='Chaisewidthz', minValue=4, maxValue=6, value=4 ) # slider5= cmds.intSliderGrp( field=True, label='ChaiseWidthx', minValue=2, maxValue=6, value=5 ) # slider6= cmds.intSliderGrp( field=True, label='ChaiseHeight', minValue=2, maxValue=10, value=4 ) # slider7= cmds.intSliderGrp( field=True, label='Distance', minValue=-10, maxValue=10, value=-5 ) # #slider8= cmds.intSliderGrp( field=True, label='Base', minValue=-10, maxValue=10, value=-5 ) # cmds.button(label = 'Create Table', c='table()') # cmds.button(label = 'Create Chaise', c='Chaise()') # cmds.button(label = 'Base', c='Base()') # cmds.separator(style='none', h=10, w=10) # cmds.showWindow()
def comode(): Counter_H = cmds.intSliderGrp(slider1, q=True, value=True) Counter_W = cmds.intSliderGrp(slider2, q=True, value=True) Counter_d = cmds.intSliderGrp(slider3, q=True, value=True) #Var Counter_support spt_Counter = 0.5 spt_Counter_W = Counter_W - 1.0 spt_Counter_d = Counter_d - 1.0 offset = 0.5 #Var Tirroire seperation = 3 nbr_Tiroire = 3 H_tirroire = 1.0 W_Tirroire = Counter_W - 2.0 D_Tirroire = 1.0 #var handle H_Handle = 0.2 w_Handle = 0.5 D_Handle = 0.2 H_topCounter = 1.0 #top counter cmds.polyCube(h=spt_Counter, w=spt_Counter_W, d=spt_Counter_d, n="Counter_support") cmds.polyBevel("Counter_support", segments=2, offset=0.01) cmds.move((Counter_W / 2.0 % offset), offset, (Counter_d / 2.0 % offset)) #counter cmds.polyCube(h=Counter_H, w=Counter_W, d=Counter_d, n="Counter_") cmds.polyBevel("Counter_", segments=2, offset=0.01) cmds.move(0, (spt_Counter / 2.0 + offset) + (Counter_H / 2.0), 0) #top counter cmds.polyCube(h=H_topCounter / 2, w=Counter_W, d=spt_Counter_d + 1.5, n="Top_counter_") cmds.polyBevel("Top_counter_", segments=2, offset=0.01) cmds.move((Counter_W / 2.0 % offset), (Counter_H) + (H_topCounter), (Counter_d / 2.0 % offset)) #group: cmds.group("Top_counter_", "Counter_", "Counter_support", name="Comode") #Tiroire <=======================================La zone des loops for t in range(nbr_Tiroire): cmds.polyCube(h=H_tirroire, w=W_Tirroire, d=D_Tirroire, n="Tirroire_" + str(t)) cmds.polyBevel("Tirroire_" + str(t), offset=0.01) cmds.move((W_Tirroire / Counter_W - offset), (seperation / 2.0 * (t) + H_tirroire + offset * 2), (Counter_d / 2.0 - 0.3)) cmds.parent('Tirroire_' + str(t), 'Comode', relative=True ) #<=============================solution temporaire ? #Handle for f in range(nbr_Tiroire): cmds.polyCube(h=H_Handle, w=w_Handle, d=D_Handle, n="Handle_" + str(f)) cmds.polyBevel("Handle_" + str(f), offset=0.01) cmds.move((W_Tirroire / Counter_W - offset), (seperation / 2.0 * (f) + H_tirroire + offset * 2), (Counter_d / 2.0 - 0.3 + offset)) cmds.parent('Handle_' + str(f), 'Comode', relative=True ) #<=============================solution temporaire ?
def createHoles(block, blockDepth, blockSizeX, blockSizeY, blockSizeZ, axelHoles, holeOffset, holeOffsetZ): beam = block #Holes are offset on reg blocks (in between bumps) if(holeOffset == True): holeArray = [] for i in range(blockDepth-1): #outer, larger radius, slight indent hole = cmds.polyCylinder(r=0.3, h=0.1, sz=1) cmds.rotate(90, rotateX=True) cmds.rotate(90, rotateY=True) cmds.move(((blockSizeY/2.0) + 0.1), moveY=True, a=True) cmds.move(((i * 0.8) - (blockSizeZ/2.0)+ holeOffsetZ), moveZ=True, a=True) cmds.move((blockSizeX/2.0), moveX = True, a = True) holeArray.append(hole) #same as above, other side of block hole = cmds.polyCylinder(r=0.3, h=0.1, sz=1) cmds.rotate(90, rotateX=True) cmds.rotate(90, rotateY=True) cmds.move(((blockSizeY/2.0) +0.1), moveY=True, a=True) cmds.move(((i * 0.8) - (blockSizeZ/2.0)+ holeOffsetZ), moveZ=True, a=True) cmds.move((-1*(blockSizeX/2.0)), moveX = True, a = True) holeArray.append(hole) #smaller radius, full way through block hole = cmds.polyCylinder(r=0.25, h=blockSizeX, sz=1) cmds.rotate(90, rotateX=True) cmds.rotate(90, rotateY=True) cmds.move(((blockSizeY/2.0) + 0.1), moveY=True, a=True) cmds.move(((i * 0.8) - (blockSizeZ/2.0) + holeOffsetZ), moveZ=True, a=True) holeArray.append(hole) cmds.select(beam) for hole in holeArray: cmds.select(hole, add=True) finalBlock = cmds.polyCBoolOp(op=2) #Holes on rounded beams are not offset, are flush with rounded ends else: #if no axel holes if(axelHoles == 0): start = 0 end = 1 if(axelHoles ==1): start = 1 end = 1 if(axelHoles ==2): start = 1 end = 0 holeArray = [] for i in range(start, blockDepth+end): #outer, larger radius, slight indent hole = cmds.polyCylinder(r=0.3, h=0.1, sz=1) cmds.rotate(90, rotateX=True) cmds.rotate(90, rotateY=True) cmds.move((blockSizeY/2.0), moveY=True, a=True) cmds.move(((i * 0.8) - (blockSizeZ/2.0)+ holeOffsetZ), moveZ=True, a=True) cmds.move((blockSizeX/2.0), moveX = True, a = True) holeArray.append(hole) #same as above, other side of block hole = cmds.polyCylinder(r=0.3, h=0.1, sz=1) cmds.rotate(90, rotateX=True) cmds.rotate(90, rotateY=True) cmds.move((blockSizeY/2.0), moveY=True, a=True) cmds.move(((i * 0.8) - (blockSizeZ/2.0)+ holeOffsetZ), moveZ=True, a=True) cmds.move((-1*(blockSizeX/2.0)), moveX = True, a = True) holeArray.append(hole) #smaller radius, full way through block hole = cmds.polyCylinder(r=0.25, h=blockSizeX, sz=1) cmds.rotate(90, rotateX=True) cmds.rotate(90, rotateY=True) cmds.move((blockSizeY/2.0), moveY=True, a=True) cmds.move(((i * 0.8) - (blockSizeZ/2.0)+ holeOffsetZ), moveZ=True, a=True) holeArray.append(hole) if(axelHoles == 1): cmds.select(clear=True) #each part of axel shape - 0.19 #each oart comes out 0.15 #total axle diameter = 0.48, axle hole diam = 0.49 hole = cmds.polyCube(h = 0.19, w=2, d=0.19) cmds.move((blockSizeY/2.0), moveY=True, a=True) cmds.move((((-blockSizeZ)/2.0)+ holeOffsetZ), moveZ=True, a=True) holeName = cmds.ls(hole)[0] cmds.select(holeName+".f[0]") cmds.select(holeName+".f[1]", add=True) cmds.select(holeName+".f[2]", add=True) cmds.select(holeName+".f[3]", add=True) cmds.polyExtrudeFacet(lt=(0,0,0.15), kft=False) cmds.select(hole) cmds.polyBevel(sg=2, oaf=True, fn=True) holeArray.append(hole) if(axelHoles == 2): cmds.select(clear=True) hole = cmds.polyCube(h = 0.19, w=2, d=0.19) cmds.move((blockSizeY/2.0), moveY=True, a=True) cmds.move((((-blockSizeZ)/2.0)+ holeOffsetZ), moveZ=True, a=True) holeName = cmds.ls(hole)[0] cmds.select(holeName+".f[0]") cmds.select(holeName+".f[1]", add=True) cmds.select(holeName+".f[2]", add=True) cmds.select(holeName+".f[3]", add=True) cmds.polyExtrudeFacet(lt=(0,0,0.15), kft=False) cmds.select(hole) cmds.polyBevel(sg=2, oaf=True, fn=True) holeArray.append(hole) cmds.select(clear=True) hole = cmds.polyCube(h = 0.19, w=2, d=0.19) cmds.move((blockSizeY/2.0), moveY=True, a=True) cmds.move((((blockSizeZ)/2.0)- holeOffsetZ), moveZ=True, a=True) holeName = cmds.ls(hole)[0] cmds.select(holeName+".f[0]") cmds.select(holeName+".f[1]", add=True) cmds.select(holeName+".f[2]", add=True) cmds.select(holeName+".f[3]", add=True) cmds.polyExtrudeFacet(lt=(0,0,0.15), kft=False) cmds.select(hole) cmds.polyBevel(sg=2, oaf=True, fn=True) holeArray.append(hole) cmds.select(beam) for hole in holeArray: cmds.select(hole, add=True) #punch holes through rounded block finalBlock = cmds.polyCBoolOp(op=2, ch=False, n="Block" + str(rnd.randint(1000,9999))) return finalBlock
def polyBevel(*args, **kwargs): res = cmds.polyBevel(*args, **kwargs) if not kwargs.get('query', kwargs.get('q', False)): res = _factories.maybeConvert(res, _general.PyNode) return res
def createBlocks(*args): ''' -Query GUI Values- ''' horizontalCount = cmds.intField('horizontalCount', q=True, value=True) verticalCount = cmds.intField('verticalCount', q=True, value=True) blockScaling = cmds.floatField('blockScaling', q=True, value=True) blockSpacing = cmds.floatField('blockSpacing', q=True, value=True) blockBevel = cmds.intField('blockBevel', q=True, value=True) addCollision = cmds.checkBox('addCollision', q=True, value=True) ''' -Create Geo Grp- ''' if cmds.objExists('blockMainGeo_grp'): blockMainGeoGrp = 'blockMainGeo_grp' else: blockMainGeoGrp = cmds.group(n='blockMainGeo_grp', em=True) ''' -Create Rig Grp- ''' if cmds.objExists('blockMainRig_grp'): blockMainRigGrp = 'blockMainRig_grp' else: blockMainRigGrp = cmds.group(n='blockMainRig_grp', em=True) ''' -Create Controller Grp- ''' if cmds.objExists('blockController_grp'): blockControllerGrp = 'blockController_grp' else: blockControllerGrp = cmds.group(n='blockController_grp', em=True) ''' -Create Geo Layer- ''' if cmds.objExists('blockGeo_layer'): blockGeoLayer = 'blockGeo_layer' else: blockGeoLayer = cmds.createDisplayLayer(n='blockGeo_layer') ''' -Create Controller Layer- ''' if cmds.objExists('blockController_layer'): blockControllerLayer = 'blockController_layer' else: blockControllerLayer = cmds.createDisplayLayer( n='blockController_layer') cmds.editDisplayLayerMembers(blockControllerLayer, blockControllerGrp) ''' -Build Controller- ''' if cmds.objExists('blockTop*_controller'): cmds.select('blockTop*_controller') versionCount = cmds.ls(sl=True) versionCount = len(versionCount) + 1 versionCount = str(versionCount) else: versionCount = '1' blockTopScaleX = (blockScaling * horizontalCount * 0.5) + ( (horizontalCount - 1) * blockSpacing * 0.5) + blockScaling blockTopScaleZ = (blockScaling * verticalCount * 0.5) + ( (verticalCount - 1) * blockSpacing * 0.5) + blockScaling blockTopController = cmds.curve(n='blockTop' + versionCount + '_controller', p=[(-blockTopScaleX, 0, -blockTopScaleZ), (blockTopScaleX, 0, -blockTopScaleZ), (blockTopScaleX, 0, blockTopScaleZ), (-blockTopScaleX, 0, blockTopScaleZ), (-blockTopScaleX, 0, -blockTopScaleZ)], d=1) blockController = cmds.circle(n='block' + versionCount + '_controller', nr=[0, 1, 0], r=blockScaling, ch=False)[0] radiusScaleAttr = createAttr(blockController, 'radiusScale', [0, 1]) cmds.setAttr(blockController + '.translateY', blockScaling * 10) cmds.makeIdentity(blockController, apply=True, t=True, r=True, s=True, n=0) cmds.parent(blockController, blockTopController) cmds.parent(blockTopController, blockControllerGrp) blockRigTop = cmds.group(n='blockRigTop' + versionCount + '_grp', p=blockMainRigGrp, em=True) cmds.parentConstraint(blockTopController, blockRigTop, mo=True) cmds.scaleConstraint(blockTopController, blockRigTop, mo=True) blockCount = horizontalCount * verticalCount ''' -Progress Bar- ''' progressName = progressBar('Building Blocks', blockCount) for block in range(blockCount): ''' -Block Count- ''' if cmds.objExists('block*_geo'): cmds.select('block*_geo') blockVersion = cmds.ls(sl=True) blockVersion = len(blockVersion) + 1 blockVersion = str(blockVersion) else: blockVersion = '1' blockGeoGrp = cmds.group(n='blockGeo' + blockVersion + '_grp', p=blockMainGeoGrp, em=True) blockRigGrp = cmds.group(n='blockRig' + blockVersion + '_grp', p=blockRigTop, em=True) ''' -Create Block- ''' blockGeo = cmds.polyCube(n='block' + blockVersion + '_geo', w=blockScaling, h=blockScaling, d=blockScaling, ch=False)[0] cmds.parent(blockGeo, blockGeoGrp) cmds.editDisplayLayerMembers(blockGeoLayer, blockGeo) ''' -Extrude the Top poly- ''' extrudeTop = cmds.polyExtrudeFacet(blockGeo + '.f[1]')[0] cmds.setAttr(extrudeTop + ".localScale", 0.7, 0.7, 0.7, type='double3') cmds.setAttr(extrudeTop + ".localTranslate", 0, 0, blockScaling * 0.05, type='double3') ''' -Translate Block to Ground Level- ''' blockTop = cmds.xform(blockGeo + '.f[9]', ws=True, q=True, t=True) cmds.setAttr(blockGeo + '.translateY', -blockTop[1]) ''' -Setup Distance- ''' blockBaseLoc = cmds.spaceLocator(n='blockBase' + blockVersion + '_loc')[0] blockEndLoc = cmds.spaceLocator(n='blockEnd' + blockVersion + '_loc')[0] blockTopLoc = cmds.spaceLocator(n='blockTop' + blockVersion + '_loc')[0] blockLoc = cmds.spaceLocator(n='block' + blockVersion + '_loc')[0] cmds.parent(blockBaseLoc, blockEndLoc, blockLoc, blockTopLoc, blockRigGrp) cmds.parentConstraint(blockController, blockTopLoc, blockEndLoc) cmds.setAttr(blockTopLoc + '.translateY', blockScaling * 10) ''' -Create Top Collision- ''' if addCollision == True: collisionBlockGeo = cmds.duplicate(blockGeo, n='collisionBlock' + blockVersion + '_geo')[0] cmds.delete(collisionBlockGeo + '.f[0]', collisionBlockGeo + '.f[2:5]') cmds.makeIdentity(collisionBlockGeo, apply=True, t=True, r=True, s=True, n=0) cmds.makeIdentity(collisionBlockGeo) cmds.delete(collisionBlockGeo, ch=True) ''' -Collision Dynamics- ''' collisionDyn = cmds.rigidBody(collisionBlockGeo, n='collisionBlock' + blockVersion + '_dyn', active=False) cmds.hide(collisionBlockGeo) cmds.pointConstraint(blockLoc, collisionBlockGeo) ''' -Zero Out Block Values- ''' cmds.makeIdentity(blockGeo, apply=True, t=True, r=True, s=True, n=0) cmds.makeIdentity(blockGeo) cmds.delete(blockGeo, ch=True) ''' -Create and Place Joints- ''' cmds.select(cl=True) blockBaseJnt = cmds.joint(n='blockBase' + blockVersion + '_jnt') blockBottom = cmds.xform(blockGeo + '.f[0]', ws=True, q=True, t=True) cmds.setAttr(blockBaseJnt + '.translateY', blockBottom[1]) blockEndJnt = cmds.joint(n='blockEnd' + blockVersion + '_jnt') cmds.setAttr(blockEndJnt + '.translateY', -blockBottom[1]) cmds.setAttr(blockBaseJnt + '.radius', blockScaling * 0.1) cmds.setAttr(blockEndJnt + '.radius', blockScaling * 0.1) cmds.parentConstraint(blockLoc, blockEndJnt) cmds.parent(blockBaseJnt, blockRigGrp) ''' -Skin Block to Joints- ''' blockSkin = cmds.skinCluster(blockGeo, blockBaseJnt, blockEndJnt, n='block' + blockVersion + '_skin')[0] cmds.skinPercent(blockSkin, blockGeo + '.vtx[0:1]', blockGeo + '.vtx[6:7]', transformValue=[(blockBaseJnt, 1), (blockEndJnt, 0)]) cmds.skinPercent(blockSkin, blockGeo + '.vtx[2:5]', blockGeo + '.vtx[8:11]', transformValue=[(blockBaseJnt, 0), (blockEndJnt, 1)]) ''' -Bevel the Block- ''' if blockBevel >= 1: cmds.polyBevel(blockGeo + '.e[0:19]', offset=0.08, offsetAsFraction=1, autoFit=1, segments=blockBevel, worldSpace=1, uvAssignment=0, fillNgons=1, mergeVertices=1, mergeVertexTolerance=0.0001, smoothingAngle=30, miteringAngle=180, angleTolerance=180, ch=1) cmds.bakePartialHistory(blockGeo, prePostDeformers=True) ''' -Radius Scale- ''' try: blockScaleCurve1 = blockScaleCurve1 blockEndConstraint = cmds.parentConstraint(blockEndLoc, name=True, q=True) blockEndAlias = con = cmds.parentConstraint(blockEndLoc, weightAliasList=True, q=True) blockEndConstraint1 = blockEndConstraint + '.' + blockEndAlias[0] blockEndConstraint2 = blockEndConstraint + '.' + blockEndAlias[1] cmds.connectAttr(blockScaleCurve1 + '.output', blockEndConstraint1) cmds.connectAttr(blockScaleCurve2 + '.output', blockEndConstraint2) except: blockEndConstraint = cmds.parentConstraint(blockEndLoc, name=True, q=True) blockEndAlias = con = cmds.parentConstraint(blockEndLoc, weightAliasList=True, q=True) blockEndConstraint1 = blockEndConstraint + '.' + blockEndAlias[0] blockEndConstraint2 = blockEndConstraint + '.' + blockEndAlias[1] cmds.setDrivenKeyframe(blockEndConstraint1, cd=radiusScaleAttr, dv=0, v=1) cmds.setDrivenKeyframe(blockEndConstraint1, cd=radiusScaleAttr, dv=1, v=0) cmds.setDrivenKeyframe(blockEndConstraint2, cd=radiusScaleAttr, dv=0, v=0) cmds.setDrivenKeyframe(blockEndConstraint2, cd=radiusScaleAttr, dv=1, v=1) blockScaleCurve1 = cmds.listConnections(blockEndConstraint1, source=True, type="animCurve")[0] blockScaleCurve2 = cmds.listConnections(blockEndConstraint2, source=True, type="animCurve")[0] ''' -Find Distance- ''' blockDistance = cmds.shadingNode('distanceBetween', asUtility=True, name='block' + blockVersion + '_distance') blockBaseLocShape = cmds.listRelatives(blockBaseLoc, shapes=True)[0] blockEndLocShape = cmds.listRelatives(blockEndLoc, shapes=True)[0] cmds.connectAttr(blockBaseLocShape + '.worldPosition [0]', blockDistance + '.point1') cmds.connectAttr(blockEndLocShape + '.worldPosition [0]', blockDistance + '.point2') ''' -Translate Box Anim- ''' cmds.setDrivenKeyframe(blockLoc + '.translateY', cd=blockDistance + '.distance', dv=blockScaling * 10, v=blockScaling * 0) cmds.setDrivenKeyframe(blockLoc + '.translateY', cd=blockDistance + '.distance', dv=blockScaling * 9.8, v=-blockScaling * 0.2) cmds.setDrivenKeyframe(blockLoc + '.translateY', cd=blockDistance + '.distance', dv=blockScaling * 5.2, v=blockScaling * 5.2) cmds.setDrivenKeyframe(blockLoc + '.translateY', cd=blockDistance + '.distance', dv=blockScaling * 5, v=blockScaling * 5) cmds.setDrivenKeyframe(blockLoc + '.translateY', cd=blockDistance + '.distance', dv=blockScaling * 0.2, v=-blockScaling * 0.2) cmds.setDrivenKeyframe(blockLoc + '.translateY', cd=blockDistance + '.distance', dv=blockScaling * 0, v=blockScaling * 0) ''' -Block Layout- ''' blockScaling2 = blockScaling + blockSpacing if block == 0: traX = ((horizontalCount - 1) * -0.5 * blockScaling2) traZ = ((verticalCount - 1) * -0.5 * blockScaling2) cmds.setAttr(blockRigGrp + '.translate', traX, 0, traZ) horizontalCountDown1 = horizontalCount - 1 horizontalCountDown2 = horizontalCount verticalCountDown = 0 else: if horizontalCountDown1 == 0: horizontalCountDown1 = horizontalCount horizontalCountDown2 = horizontalCount verticalCountDown = verticalCountDown - 1 horizontalCountDown1 = horizontalCountDown1 - 1 horizontalCountDown2 = horizontalCountDown2 - 1 traX = (((horizontalCount - 1) * -0.5 + horizontalCountDown2) * blockScaling2) traZ = (((verticalCount - 1) * -0.5 - verticalCountDown) * blockScaling2) cmds.setAttr(blockRigGrp + '.translate', traX, 0, traZ) cmds.parentConstraint(blockController, blockTopLoc, mo=True) cmds.hide(blockRigGrp) cmds.progressBar(progressName, e=True, step=1) ''' -Close Progress Bar- ''' progressBar('', 0)
def main(name="wheel", terrain=None, radius=1, scale=1): if terrain == None: l = mc.ls(sl=True, o=True) or [] for n in l: if mc.nodeType(n) == "mesh": terrain = n break else: l2 = mc.listRelatives(n, pa=True, s=True, ni=True) or [] for n2 in l2: if mc.nodeType(n2) == "mesh": terrain = n break if terrain: break grp, ctrl = common.control(name=name+"_placer", color=6, radius=radius*3, shape="square", hideAttr=["tx","tz","rx","ry","rz","sx","sy","sz","v"], lockAttr=["tx","tz","rx","ry","rz","sx","sy","sz"]) grp = mc.rename(grp, name+"_grp") susp = mc.curve(d=1, p=[(0,-0.5,0),(0,0.5,0)], k=(0,1), n=name+"_susp") mc.setAttr(susp+".template", True) susp = mc.parent(susp, ctrl)[0] grp2, ctrl2 = common.control(name=name, numOffsetGroups=1, color=13, radius=radius*1.25, normal=(1,0,0), parent=grp, lockAttr=["tx","tz","rx"], hideAttr=["tx","tz","rx","sx","sy","sz"]) tilt = mc.listRelatives(ctrl2, pa=True, p=True)[0] tilt = mc.rename(tilt, name+"_tilt_grp") mc.addAttr(ctrl2, ln="joints", at="bool", dv=True, k=True) mc.addAttr(ctrl2, ln="editJoints", at="bool", k=True) mc.addAttr(ctrl2, ln="placer", at="bool", dv=True, k=True) mc.addAttr(ctrl2, ln="wheel", at="bool", dv=True, k=True) mc.addAttr(ctrl2, ln="terrain", at="bool", dv=True, k=True) mc.addAttr(ctrl2, ln="editTerrain", at="bool", dv=False, k=True) mc.addAttr(ctrl2, ln="spin", at="double", k=True) mc.addAttr(ctrl2, ln="tilt", at="double", dv=1, k=True) mc.addAttr(ctrl2, ln="size", at="double", dv=1, min=0, k=True) mc.addAttr(ctrl2, ln="terrainDetection", at="bool", dv=True, k=True) mc.addAttr(ctrl2, ln="suspensionOffset", at="double", min=0, k=True) mc.addAttr(ctrl2, ln="suspensionLength", at="double", dv=1, min=0, k=True) mc.connectAttr(ctrl2+".placer", ctrl+"Shape.v") wheel = mc.polyCylinder(h=0.5, ax=(1,0,0), sc=1, ch=False, n=name+"_pxy")[0] mc.select(wheel+".e[0:19]", wheel+".e[20:39]") mc.polyBevel(wheel+".e[0:39]", o=0.1, ch=False) mc.setAttr(wheel+"Shape.overrideEnabled", True) mc.setAttr(wheel+"Shape.overrideDisplayType", 2) mc.setAttr(wheel+"Shape.overrideShading", 0) mc.setAttr(wheel+"Shape.overrideColor", 1) mc.setAttr(wheel+".castsShadows", 0) mc.setAttr(wheel+".receiveShadows", 0) mc.setAttr(wheel+".primaryVisibility", 0) mc.setAttr(wheel+".visibleInReflections", 0) mc.setAttr(wheel+".visibleInRefractions", 0) mc.setAttr(wheel+".doubleSided", 0) mc.connectAttr(ctrl2+".wheel", wheel+"Shape.v") mc.parent(wheel, ctrl) jnt = mc.createNode("joint", n=name+"_jnt", p=ctrl, ss=True) mc.connectAttr(wheel+".t", jnt+".t") mc.connectAttr(wheel+".r", jnt+".r") mc.connectAttr(ctrl2+".joints", jnt+".v") mc.setAttr(jnt+".radius", radius*0.5) common.selectable(ctrl2+".editJoints", jnt) common.sets("wheel", jnt, None, None) if terrain == None: terrain = _terrain.main(name=name, parent=grp) mc.connectAttr(ctrl2+".terrain", terrain+".v") r = mc.createNode("reverse", ss=True) mc.connectAttr(ctrl2+".editTerrain", r+".inputX") mc.connectAttr(r+".outputX", terrain+".template") ter_ted = mc.createNode("transform", p=ctrl, n=name+"_terrain_detection", ss=True) pc = mc.parentConstraint(ctrl2, wheel)[0] mc.pointConstraint(susp, ter_ted) gc = mc.geometryConstraint(terrain, ter_ted)[0] mc.connectAttr(ctrl2+".terrainDetection", gc+"."+terrain+"W0") susp_orig = mc.createNode("transform", p=ctrl, n=name+"_suspension_origin", ss=True) mc.pointConstraint(ter_ted, susp_orig) mc.geometryConstraint(susp, susp_orig) sPntConst = mc.pointConstraint(susp_orig, grp2)[0] mc.connectAttr(ctrl2+".suspensionOffset", susp+".ty") mc.connectAttr(ctrl2+".suspensionLength", susp+".sy") mc.connectAttr(ctrl2+".placer", susp+".v") adl = mc.createNode("addDoubleLinear", ss=True) mc.connectAttr(ctrl2+".spin", adl+".input1") mc.connectAttr(adl+".output", pc+".target[0].targetOffsetRotateX") adl = mc.createNode("addDoubleLinear", ss=True) mc.connectAttr(ctrl2+".tilt", adl+".input1") md = mc.createNode("multiplyDivide", ss=True) mc.setAttr(md+".input2Y", -1) mc.connectAttr(ctrl2+".size", md+".input1Y") mc.connectAttr(md+".outputY", tilt+".rotatePivotY") mc.connectAttr(md+".outputY", tilt+".scalePivotY") mc.connectAttr(ctrl2+".s", wheel+".s") mc.connectAttr(ctrl2+".size", sPntConst+".oy") mc.connectAttr(ctrl2+".size", ctrl2+".sx") mc.connectAttr(ctrl2+".size", ctrl2+".sy") mc.connectAttr(ctrl2+".size", ctrl2+".sz") mc.setAttr(ctrl2+".s", l=True) mc.move(0, -1, 0, tilt+".scalePivot", tilt+".rotatePivot", r=True) mc.expression(s=tilt+".rz = "+ctrl2+".ry * -"+adl+".output * 0.25", o="", ae=True, uc="all", n=name+"_wheel_exp") common.sets("wheel", None, [ctrl, ctrl2], None) mc.select(grp) mc.dgdirty(a=True) return grp, ctrl, ctrl2, wheel
def _polyBevel(self): cmds.polyBevel()
def tableChaise(): tablewidthz = cmds.intSliderGrp(slider1, q=True, value=True) tableWidthx = cmds.intSliderGrp(slider2, q=True, value=True) tableHeight = cmds.intSliderGrp(slider3, q=True, value=True) #Roundness = cmds.intSliderGrp(slider4, q=True, value=True) #mesa table = cmds.polyCube(h=0.7, w=tableWidthx, depth=tablewidthz) rtable = cmds.ls(table[0]) print(rtable) cmds.move(0, tableHeight / 2.0 - 0.3, 0) cmds.select(str(rtable[0]) + '.e[4:5]') cmds.select(str(rtable[0]) + '.e[8:9]', add=True) # cmds.select('table.e[4:5]') # cmds.select('table.e[8:9]', add=True) cmds.polyBevel3(offset=1, segments=3) cmds.polyBevel3(rtable[0], offset=0.1) #patas pataUno = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(-tableWidthx / 2.0 + 1, 0, tablewidthz / 2.0 - 1) cmds.polyBevel(offset=0.1) pataDos = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(tableWidthx / 2.0 - 1, 0, tablewidthz / 2.0 - 1) cmds.polyBevel(offset=0.1) pataTres = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(tableWidthx / 2.0 - 1, 0, -tablewidthz / 2.0 + 1) cmds.polyBevel(offset=0.1) pataCuatro = cmds.polyCube(h=tableHeight, w=1, depth=1) cmds.move(-tableWidthx / 2.0 + 1, 0, -tablewidthz / 2.0 + 1) cmds.polyBevel(offset=0.1) mir = random.randint(0, 19) crazyR = random.randint(0, 1000) tName = 'Table' + str(mir) + str(crazyR) cmds.group(table, pataUno, pataDos, pataTres, pataCuatro, n=tName) Chaisewidthz = cmds.intSliderGrp(slider4, q=True, value=True) ChaiseWidthx = cmds.intSliderGrp(slider5, q=True, value=True) ChaiseHeight = cmds.intSliderGrp(slider6, q=True, value=True) Distance = cmds.intSliderGrp(slider7, q=True, value=True) mainC = cmds.polyCube(h=1, w=ChaiseWidthx, depth=Chaisewidthz) cmds.move(0, ChaiseHeight / 2.0 - 0.3, 0) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) #patas pataUno = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, -4) cmds.polyBevel(offset=0.1) pataDos = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, Chaisewidthz / 2.0 - 0.5) cmds.rotate(-4, 0, 4) cmds.polyBevel(offset=0.1) pataTres = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(ChaiseWidthx / 2.0 - 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, 4) cmds.polyBevel(offset=0.1) pataCuatro = cmds.polyCube(h=ChaiseHeight, w=0.7, depth=0.7) cmds.move(-ChaiseWidthx / 2.0 + 0.5, 0, -Chaisewidthz / 2.0 + 0.5) cmds.rotate(4, 0, -4) cmds.polyBevel(offset=0.1) #espaldar e_uno = cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5) cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, Chaisewidthz / 2.0 - 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) e_dos = cmds.polyCube(h=ChaiseHeight, w=0.5, depth=0.5) cmds.move(-ChaiseWidthx / 2.0 + 0.2, ChaiseHeight, -Chaisewidthz / 2.0 + 1) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.1) e_tres = cmds.polyCube(h=2.5, w=1, depth=Chaisewidthz) cmds.move(-ChaiseWidthx / 2.0 + 0.5, ChaiseHeight * 1.4, 0) cmds.rotate(0, 0, 7) cmds.polyBevel(offset=0.2) cmds.polySmooth(dv=1) mir = random.randint(0, 19) crazyR = random.randint(0, 1000) rName = 'Chair' + str(mir) + str(crazyR) cmds.group(mainC, pataUno, pataDos, pataTres, pataCuatro, e_uno, e_dos, e_tres, n=rName) cmds.select(rName) cmds.move(Distance, -1, 0) cmds.duplicate(rName) cmds.move(-Distance, -1, 0) cmds.rotate(0, -180, 0) cmds.select(rName) cmds.duplicate(rName) cmds.move(0, -1, -Distance) cmds.rotate(0, 90, 0) cmds.select(rName) cmds.duplicate(rName) cmds.move(0, -1, Distance) cmds.rotate(0, -90, 0)
def createBrick(self): name = 'b' + str(self.num_b) cmds.polyCube(n=name, sx=1, sy=1, sz=1, h=1, w=2, d=1) cmds.polyBevel(n=name, segments=2, fraction=.1, offsetAsFraction=1) self.num_b += 1 return name
def hub(wheelRadius): hubRadius = wheelRadius - 1 hubWidth = 3 * 0.8 hubThickness = 0 rgb = cmds.colorSliderGrp('hubColor', q=True, rgbValue=True) outerHub = cmds.polyCylinder(r=hubRadius, h=hubWidth) cmds.move((wheelRadius), moveY=True, a=True) cmds.rotate(90, rotateX=True) innerHubL = cmds.polyCylinder(r=hubRadius-0.3, h=0.6) cmds.move((wheelRadius), moveY=True, a=True) cmds.rotate(90, rotateX=True) cmds.move(1.2,moveZ=True, r=True) innerHubR = cmds.polyCylinder(r=hubRadius-0.3, h=0.6) cmds.move((wheelRadius), moveY=True, a=True) cmds.rotate(90, rotateX=True) cmds.move(-1.2,moveZ=True, r=True) cmds.select(outerHub) cmds.select(innerHubL, add=True) cmds.select(innerHubR, add=True) hub = cmds.polyCBoolOp(op=2, ch=False) cmds.select(clear=True) pairs = [] holeArray = [] hubHoleArray =[] #outer, larger radius, slight indent for i in range(-1,2,2): hole = cmds.polyCylinder(r=0.3, h=0.2, sz=1) cmds.rotate(90, rotateX=True) cmds.move((i*0.8), moveX=True, a=True) cmds.move(-0.9,moveZ=True) pairs.append(hole) hole = cmds.polyCylinder(r=0.3, h=0.2, sz=1) cmds.rotate(90, rotateX=True) cmds.move((i*0.8), moveX=True, a=True) cmds.move(0.9,moveZ=True) pairs.append(hole) for pair in pairs: cmds.select(pair, add=True) pair1 = cmds.polyUnite(ch=False) cmds.select(pair1) pair2 = cmds.duplicate() cmds.rotate(60,rotateZ=True) cmds.select(pair1) pair3 = cmds.duplicate() cmds.rotate(120,rotateZ=True) cmds.select(pair1) cmds.select(pair2,add=True) cmds.select(pair3,add=True) hubIndents = cmds.polyUnite(ch=False) cmds.move(wheelRadius, moveY=True) cmds.select(hub) cmds.select(hubIndents, add=True) indentedHub = cmds.polyCBoolOp(op=2) holePairs = [] for i in range(-1,2,2): hole = cmds.polyCylinder(r=0.25, h=3, sz=1) cmds.rotate(90, rotateX=True) cmds.move(0,moveZ=True) cmds.move((i*0.8), moveX=True, a=True) holePairs.append(hole) cmds.select(clear=True) for pair in holePairs: cmds.select(pair, add=True) holePair1 = cmds.polyUnite(ch=False) cmds.select(holePair1) holePair2 = cmds.duplicate() cmds.rotate(60,rotateZ=True) cmds.select(holePair1) holePair3 = cmds.duplicate() cmds.rotate(120,rotateZ=True) cmds.select(holePair1) cmds.select(holePair2,add=True) cmds.select(holePair3,add=True) hubIndents = cmds.polyUnite(ch=False) cmds.move(wheelRadius, moveY=True) cmds.select(indentedHub) cmds.select(hubIndents, add=True) holedHub = cmds.polyCBoolOp(op=2) cyl = cmds.polyCylinder(r=0.3, h=2.2) cmds.move(0,moveZ=True) cmds.move((wheelRadius), moveY=True, a=True) cmds.rotate(90,rotateX=True) cmds.select(cyl) cmds.select(holedHub, add=True) hub = cmds.polyCBoolOp(op=1) axelHole = cmds.polyCube(h = 0.19, w=2.5, d=0.19) cmds.move(wheelRadius, moveY=True, a=True) holeName = cmds.ls(axelHole)[0] cmds.select(holeName+".f[0]") cmds.select(holeName+".f[1]", add=True) cmds.select(holeName+".f[2]", add=True) cmds.select(holeName+".f[3]", add=True) cmds.polyExtrudeFacet(lt=(0,0,0.15), kft=False) cmds.select(axelHole) cmds.polyBevel(sg=2, oaf=True, fn=True) cmds.rotate(90, rotateY=True) cmds.select(hub) cmds.select(axelHole,add=True) finalHub = cmds.polyCBoolOp(op=2, n="Hub" + str(rnd.randint(1000,9999))) applyMaterial(finalHub, rgb) cmds.delete(ch=True)
import maya.cmds as cmds import random selected_items = cmds.ls(selection=True) if selected_items: shapes = cmds.listRelatives(selected_items[0], shapes=True) for shape in shapes: smoothnode = cmds.polySmooth(shape) cmds.polyBevel(shape, offset=0.040, worldSpace=True) vertexPositionList = cmds.getAttr(shape + ".vrts", multiIndices=True) for i in vertexPositionList: if random.random() > 0.8: brick = cmds.polyCube(w=0.2 + (random.random() * 0.4), h=0.3, d=0.2 + (random.random() * 0.4)) vtxPos = cmds.xform(str(shape) + ".pnts[" + str(i) + "]", query=True, translation=True, worldSpace=True) cmds.move(vtxPos[0] + (random.random() - 0.5) * 0.1, vtxPos[1] + (random.random() - 0.5) * 0.05, vtxPos[2] + (random.random() - 0.5) * 0.1, brick, absolute=True) cmds.rotate((random.random() - 0.5) * 5.0, (random.random() - 0.5) * 5.0, (random.random() - 0.5) * 5.0, brick)
def createVoxelForObj(obj, startFrame = 1, endFrame = 24, voxelSize = 20.0, voxelStep = 0.5 ): """docstring for createVoxelForOb""" sel = OpenMaya.MSelectionList() dagPath = OpenMaya.MDagPath() sel.add(obj) sel.getDagPath(0, dagPath) inMesh = OpenMaya.MFnMesh( dagPath ) grpReelNames = dict() for curTime in xrange(startFrame, endFrame+1) : grpName = "frameGrp_%s".zfill(4) % int(curTime) grpReelName = cmds.group(name=grpName, empty=True) cmds.setKeyframe(grpReelName+".visibility", value=0.0, time=[curTime-0.1]) cmds.setKeyframe(grpReelName+".visibility", value=1.0, time=[curTime]) cmds.setKeyframe(grpReelName+".visibility", value=0.0, time=[curTime+1]) grpReelNames[curTime] = grpReelName for grpReelName in grpReelNames : if cmds.objExists(grpReelName) : cmds.delete(grpReelName) for curTime in xrange(startFrame, endFrame+1) : cmds.currentTime(curTime) voxelIdSet = set() #I use while just because xrange with floats is impossible i = -voxelSize/2.0 while i <= voxelSize/2.0 : j = -voxelSize/2.0 while j <= voxelSize/2.0 : for axis in ["zSide", "ySide", "xSide"] : z = 0 y = 0 x = 0 zOffset = 0 zDir = 0 yOffset = 0 yDir = 0 xOffset = 0 xDir = 0 if axis == "zSide" : x = i y = j zOffset = 10000 zDir = -1 elif axis == "ySide" : x = i z = j yOffset = 10000 yDir = -1 elif axis == "xSide" : y = i z = j xOffset = 10000 xDir = -1 raySource = OpenMaya.MFloatPoint( x+xOffset, y+yOffset, z+zOffset ) rayDirection = OpenMaya.MFloatVector(xDir, yDir, zDir) faceIds=None triIds=None idsSorted=False space=OpenMaya.MSpace.kWorld maxParam=99999999 testBothDirections=False accelParams=inMesh.autoUniformGridParams() sortHits=False hitPoints = OpenMaya.MFloatPointArray() hitRayParam=None hitFacePtr = None#OpenMaya.MScriptUtil().asIntPtr() hitTriangle=None hitBary1=None hitBary2=None hit = inMesh.allIntersections(raySource, rayDirection, faceIds, triIds, idsSorted, space, maxParam, testBothDirections, accelParams, sortHits, hitPoints, hitRayParam, hitFacePtr, hitTriangle, hitBary1, hitBary2) if not hit : continue # for each interestected points for k in xrange(hitPoints.length()) : cubePosX = round(hitPoints[k].x/voxelStep)*voxelStep cubePosY = round(hitPoints[k].y/voxelStep)*voxelStep cubePosZ = round(hitPoints[k].z/voxelStep)*voxelStep cubeId = "%s%s%s" % (cubePosX, cubePosY, cubePosZ) if cubeId in voxelIdSet : continue else: voxelIdSet.add(cubeId) myCube = cmds.polyCube(width=voxelStep, height=voxelStep, depth=voxelStep)[0] cmds.polyBevel(myCube, offset=0.02) cmds.parent(myCube, grpReelNames[curTime]) cmds.setAttr(myCube+".translate", cubePosX, cubePosY, cubePosZ) j += voxelStep i += voxelStep