def generateGeometry(): webCurves = determineSelectedCurves() stringThickness = cmds.intSliderGrp('stringThickness', q=True, v=True) stringThickness = float(stringThickness) stringThickness = 0.002 * stringThickness """ Create circle curve with radius based on stringThickness as webExtrudeMap """ cmds.circle(nr=(0, 0, 0), c=(0, 0, 0), sw=360, r=stringThickness, n='webExtrudeMap') circleGeo = 'webExtrudeMap' for web in webCurves: """ Extrude circle curve along web curve to create geometry (po=0 is nurbs surface, po=1 is polygons, po=3 is bezier surface) """ cmds.extrude(circleGeo, web, ch=True, rn=False, po=1, et=2, ucp=1, fpt=1, upn=1, rotation=0, scale=1, rsp=1, n='web') cmds.delete(web) cmds.delete(circleGeo)
def cycloGeoCreation(namespace, name): pp1 = [-12, -2.6394186146319176e-15, 11] pp2 = [-12, 15.735990524291992, -7.29987907409668] pp3 = [-12, -2.6394186146319176e-15, -4.922739028930664] pp4 = [-12, 0.18094894289970398, -5.832431793212891] pp5 = [-12, 0.696247935295105, -6.603630065917969] pp6 = [-12, 1.4674474000930786, -7.118930816650391] pp7 = [-12, 2.37713885307312, -7.29987907409668] pp8 = [-12, 12.396276473999023, -7.29987907409668] pp9 = [-12, 9.056564331054688, -7.29987907409668] pp10 = [-12, 5.716851234436035, -7.29987907409668] pp11 = [-12, -2.6394186146319176e-15, -0.9603691101074219] pp12 = [-12, -2.6394186146319176e-15, 3.002007007598877] pp13 = [-12, -2.6394186146319176e-15, 7] cmds.curve(n=namespace + ':tempCurve', d=1, p=[ pp1, pp13, pp12, pp11, pp3, pp4, pp5, pp6, pp7, pp10, pp9, pp8, pp2 ]) cmds.extrude(namespace + ':tempCurve', ch=True, rn=False, po=1, et=0, upn=0, d=[1, 0, 0], length=24, scale=1, dl=1, n=namespace + ':' + name) tesselateNode = cmds.listHistory(namespace + ':' + name, pdo=True)[0] cmds.setAttr(tesselateNode + '.polygonType', 1) cmds.setAttr(tesselateNode + '.format', 2) cmds.setAttr(tesselateNode + '.uNumber', 1) cmds.setAttr(tesselateNode + '.vNumber', 6) cmds.polyNormal(namespace + ':' + name, ch=False) cmds.delete(namespace + ':' + name, ch=True) cmds.delete(namespace + ':tempCurve') cmds.select(cl=True) cycloShader = cmds.shadingNode('lambert', name=namespace + ':' + 'cyclo_MAT', asShader=True) cycloShaderSG = cmds.sets(name=namespace + ':' + 'cyclo_MAT_SG', empty=True, renderable=True, noSurfaceShader=True) cmds.connectAttr(cycloShader + '.outColor', cycloShaderSG + '.surfaceShader') cmds.setAttr(cycloShader + '.color', 0.9, 0.9, 0.9, type='double3') cmds.sets(namespace + ':' + name, e=True, forceElement=cycloShaderSG) activateSmoothPreview(namespace + ':' + name)
def draw_tower(self): """ Draw the panoptical tower. """ #column = cmds.cylinder(r=.1, heightRatio=10, p=[0,0,0]) tower = cmds.circle( nr=(1, 0, 0), c=(0, 0, 0), r=.1) cmds.extrude(tower, et=0, d=(1,0,0), l=3) pointer = cmds.curve(p=[(0, 0, 0), (0, 2, 0)], degree=1) cmds.extrude(pointer, et=0, d=(1,0,0), l=3)
def visualizeDropoff(node): ''' ''' shapeCrv, cirNode = mc.circle(n=node+'_visCircle') mc.connectAttr(node+'.dropoff', cirNode+'.radius', f=True) pathCrv = node.replace('_mod', '_baseCrv_crv') # make loft mc.extrude(shapeCrv, pathCrv, et=2, fixedPath=True, useComponentPivot=1, useProfileNormal=1)
def forward ( turtle, _length): newPosition = [ turtle.position[0] + (turtle.heading[0]* _length) , turtle.position[1] + (turtle.heading[1] * _length), turtle.position[2] + (turtle.heading[2] * _length)] if turtle.pen == True: cmds.curve(p = [turtle.position, newPosition ], d = 1, name = 'curve' + str(turtle.curveNum) ) if turtle.fill[0] == 'poly': cmds.polyPlane (name = 'plane' + str(turtle.curveNum), w = turtle.size, h = turtle.size, sx = 1, sy = 1) cmds.setAttr ( 'plane' + str(turtle.curveNum) + '.translate', turtle.position[0], turtle.position[1], turtle.position[2], type = 'double3' ) cmds.polyExtrudeFacet ( 'plane' + str(turtle.curveNum) , inc = 'curve'+ str(turtle.curveNum) ) cmds.setAttr ( 'polyExtrudeFace'+ str(turtle.curveNum + 1) + '.taper' , turtle.sf) #taper branch elif turtle.fill[0] == 'nurbs': cmds.circle( center = turtle.position, radius = turtle.size, normal = turtle.heading, sections = 1, name = 'circle' + str(turtle.curveNum) ) cmds.extrude ( 'circle' + str(turtle.curveNum), 'curve' + str(turtle.curveNum), et = 2, upn = True, scale = turtle.sf, name = 'plane' + str(turtle.curveNum)) turtle.curveNum += 1 #increment curve num turtle.position = newPosition #update position
def draw(self): circle1 = cmds.circle( nr=(1, 0, 0), c=(0, 0, 0), sw=self.sweep, r=self.start_radius ) circle2 = cmds.circle( nr=(1, 0, 0), c=(0, 0, 0), sw=self.sweep, r=self.end_radius ) l1 = cmds.loft(circle1, circle2) # curves crv = cmds.curve(p=[(0, self.start_radius, 0), (0, self.end_radius, 0)], degree=1) crv2 = cmds.duplicate(crv) cmds.rotate(str(self.sweep) + 'deg', 0, 0, r=True) extrusions = [] for e in [circle1, circle2, crv, crv2]: extrusions.append(cmds.extrude(e, et=0, d=(1,0,0), l=self.height)) cmds.delete(e) pieces = extrusions + [l1] group = cmds.group(*[e[0] for e in pieces]) cmds.move(0,0,0, group+".scalePivot",group+".rotatePivot", absolute=True) cmds.setKeyframe(group, attribute='rotateX', t='0sec', value=self.rotation) return (pieces, group)
def visualizeDropoff(node): ''' ''' shapeCrv, cirNode = mc.circle(n=node + '_visCircle') mc.connectAttr(node + '.dropoff', cirNode + '.radius', f=True) pathCrv = node.replace('_mod', '_baseCrv_crv') # make loft mc.extrude(shapeCrv, pathCrv, et=2, fixedPath=True, useComponentPivot=1, useProfileNormal=1)
def extrude(self,caps=True): """ extrudes a tube along the NURBS curve """ self.curve2 = mc.duplicate(self.origCurve, name=self.origCurve+"_copy")[0] # select the first CV of the path (curve) mc.select("%s.cv[0]"%self.curve2,replace=True) # figure out where to put the circle and which way to point it circleCenter = mc.xform(q=True,ws=True,t=True) circleNormal = mc.pointOnCurve(self.curve2, parameter=0, tangent=True) # create a circle to use for extrusion circle = mc.circle(radius=self.radius, center=circleCenter, normal=circleNormal)[0] # extrude! extrusion = mc.extrude( circle, self.curve2, n="nurbsTubeTrace", extrudeType=2, range=True )[0] self.traceBits = [extrusion, self.curve2, self.origCurve, circle] if caps: # select the first isoparm mc.select(extrusion+".v[%f]"%cu.findParamAtArcPercent( self.origCurve, 0.0)) # create planar surface begCap = mc.planarSrf(n="cap1")[0] # select the last isoparm mc.select(extrusion+".v[%f]"%cu.findParamAtArcPercent( self.origCurve, 1.0)) # create planar surface endCap = mc.planarSrf(n="cap2")[0] mc.setKeyframe( endCap+".visibility", t=self.timeSpan[1]-1, v=0.0 ) mc.setKeyframe( endCap+".visibility", t=self.timeSpan[1], v=1.0 ) # add the caps to the traceBits list self.traceBits.extend([begCap,endCap]) return extrusion
def dessCourbe(formule, puissance, pDepart, taille, epaisseur, getX): pDepX = pDepart[0] pDepY = pDepart[1] pDepZ = pDepart[2] c = cmds.curve(point=[tuple(pDepart)]) if (formule == "cLog"): for x in range(1, taille + 1): cmds.curve(c, a=True, p=[(pDepX + math.log(x, puissance * 1.3), pDepY + x, pDepZ)]) getPosDeb = (pDepX + math.log(getX, puissance * 1.3), pDepY + getX, pDepZ) getPosFin = (pDepX + math.log(taille, puissance * 1.3), pDepY + taille, pDepZ) if (formule == "cSin"): for x in range(1, taille + 1): cmds.curve(c, a=True, p=[((pDepX + math.sin(x) / x * puissance * 10) + math.log(x, puissance * 1.3), pDepY + x, pDepZ)]) getPosDeb = ((pDepX + math.sin(getX) / getX * puissance * 10) + math.log(getX, puissance * 1.3), pDepY + getX, pDepZ) getPosFin = ((pDepX + math.sin(taille) / taille * puissance * 10) + math.log(taille, puissance * 1.3), pDepY + taille, pDepZ) if (formule == "cDrt"): for x in range(1, taille + 1): cmds.curve(c, a=True, p=[(pDepX, pDepY + x, pDepZ)]) getPosDeb = (pDepX, pDepY + getX, pDepZ) getPosFin = (pDepX, pDepY + taille, pDepZ) cercle = cmds.circle(nr=(0, 1, 0), r=epaisseur) #cercle = cmds.polyPlane( w=0.1, h=0.1, sx=1, sy=1 ) cmds.move(pDepart[0], pDepart[1], pDepart[2]) cmds.rename("yo" + str(x)) cmds.extrude("yo" + str(x), c, et=2) cmds.delete("yo" + str(x)) cmds.delete(c) return getPosDeb, getPosFin
def CurveExtruder(profileArray, shapesArray): polygonTypeQuery = cmds.optionMenu("OutputTypeQuery", query=True, value=0) rotationValue = cmds.intField("RotateAlongValue", query=True, value=True) if polygonTypeQuery == "NURBS": polygonTypeQuery = 0 else: polygonTypeQuery = 1 for curva in shapesArray: cmds.select(curva) cmds.extrude(profileArray[0], curva, extrudeType=2, fixedPath=True, useComponentPivot=1, useProfileNormal=True, constructionHistory=False, polygon=polygonTypeQuery, rotation=rotationValue) cmds.delete(constructionHistory=True)
def __makeMesh(self,curva): scale_0 = self.ui.spin_radius.value() scale_1 = self.ui.spin_radius_1.value() scale = self.ui.spin_radius.value() if (scale_0 >= scale_1): tempMaior = scale_0 tempMenor = scale_1 else: tempMaior = scale_1 tempMenor = scale_0 scale_extrude = tempMenor/tempMaior position = cmds.pointOnCurve(curva, top=True, pr=0, position=True) tangent = cmds.pointOnCurve(curva, top=True, pr=0, normalizedTangent=True) angle = cmds.angleBetween(er=True, v1=(0.0, 1.0, 0.0), v2=tangent) circle = cmds.circle(nr=(0, 1, 0), c=(0, 0, 0), degree=3, sections=16, r = 0.5) cmds.scale(tempMaior, tempMaior, tempMaior, circle[0]) cmds.move(position[0], position[1], position[2], circle[0]) cmds.rotate(angle[0], angle[1], angle[2], circle[0]) extrude = cmds.extrude(circle[0], curva, constructionHistory = True, range = True, polygon = 0, extrudeType = 2, useComponentPivot = 0, fixedPath = 0, useProfileNormal = 1, rotation = 0, scale = scale_extrude, reverseSurfaceIfPathReversed = 1) poly = cmds.nurbsToPoly(extrude[0], matchNormalDir = True, constructionHistory = False, format = 2, polygonType = 1, uType = 3, uNumber = 1, vType = 3, vNumber = 3) cmds.delete(circle, extrude[0]) print poly return poly
def perform_multi_function(self, selfU, selfV): '''---------------------------------------------------------------------------------- Common add to list function ----------------------------------------------------------------------------------''' # maya.mel.eval( 'nurbsToPolygonsPref -un %d -vn %d;', %(selfU, ) %(selfV, ) cmds.nurbsToPolygonsPref(un=selfU, vn=selfV) # nurbsToPolygonsPref -un 1 -vn 90 ConstraintType=cmds.optionMenu(colMenu, q=1, sl=1) getObj=cmds.ls(sl=1) getParent=getObj[0] # cmds.nurbsToPolygonsPref(un=selfU, uv=selfV) for each in getObj[1:]: if ConstraintType==1:#orient cmds.orientConstraint(getParent, each, mo=1) elif ConstraintType==2:#aim cmds.aimConstraint(getParent, each, mo=1) elif ConstraintType==3:#parent cmds.parentConstraint(getParent, each, mo=1) elif ConstraintType==4:#point cmds.pointConstraint(getParent, each, mo=1) elif ConstraintType==5:#extrude_tube cmds.extrude(getParent, each, ch=1, rn=0, po=1, et=2, ucp=1, fpt=1, upn=1, rsp=1, rotation=0, scale=1) # nurbsToPoly -mnd 1 -ch 1 -f 2 -pt 1 -pc 81 -chr 0.99 -ft 0.01 -mel 0.001 -d 0.1 -ut 1 -un 24 -vt 1 -vn 1 -uch 1 -ucr 1 -cht 0.2 -es 0 -ntr 0 -mrt 0 -uss 1 "extrudedSurface3"; elif ConstraintType==6:#extrude_path cmds.nurbsToPolygonsPref(un=selfU, vn=selfV) cmds.extrude(getParent, each, ch=1, rn=0, po=1, et=1, ucp=1, fpt=1, upn=1, rotation=0, scale=1, rsp=1) # cmds.extrude(getParent, each, ch=1, rn=0, po=1, et=0, fpt=1, upn=1, rotation=0, scale=1) elif ConstraintType==7:#xform getTranslation, getRotation=self.locationXForm(getParent) each.setTranslation(getTranslation) each.setTranslation(getRotation) # elif ConstraintType==8:#xform # toolClass.point_const() # elif ConstraintType==9:#xform # toolClass.rivet() else: print "nothing performed"
def createSpiralCurve(self, baseCurve, numRounds, radius, profileScale): surfaceCV = float(numRounds+2)*(float(numRounds+2)/2.0) # duplicate curve and get the maxValue cmds.select(baseCurve, r=True) curveMaxValue = cmds.getAttr(baseCurve+".maxValue") cmds.rebuildCurve(ch=0, rpo=1, rt=0, end=1, kr=2, kcp=0, kep=1, kt=0, s=0, d=3) # create a circle profile profile = cmds.circle(nr=[0, 1, 0], c=[0, 0, 0], r=radius) # put it at the start of the baseCurve cmds.pathAnimation(profile, fm=True, f=True, fa="y", ua="x", wut=4, wu=[0, 1, 0], c=baseCurve) # extrude the profile extrudesurface = cmds.extrude(profile[0], baseCurve, et=2, sc=profileScale) # curve on surface curveonsurface = cmds.curveOnSurface(extrudesurface, append=False, uv=(0, 0)) y = 0.0 for i in range(int(surfaceCV)): y += curveMaxValue/surfaceCV x = math.fmod(y*2*surfaceCV/curveMaxValue, 8) #print x, y cmds.curveOnSurface(curveonsurface, append=True, uv=(x, y)) # duplicate the created curve cmds.duplicateCurve(ch = False) cmds.rename("duplicated_"+baseCurve) spiralCurve = cmds.ls(sl = True) cmds.rebuildCurve(ch=0, rpo=1, rt=0, end=1, kr=2, kcp=0, kep=1, kt=0, s=0, d=3) # create wire #cmds.wire(spiralCurve, dds = [(0, 100)], gw = True, en = 1.0, ce = 0.0, li = 0.0, w = baseCurve) #cmds.pickWalk(d = "up") cmds.select(spiralCurve, r = True) arcCurveGroup = cmds.group(n = "spiralCurveWire"+baseCurve+"___GRP") #delete unused nodes cmds.delete(profile) cmds.delete(extrudesurface[0]) #print "spiral curve created." return spiralCurve, arcCurveGroup
def convert(cls, *args): cls.selCrvs = cmds.ls(sl=True) polyTubeLs = [] for crv in cls.selCrvs: # create nurbs circle for profile and place to start point of the Path profile = cmds.circle(name='%s_profile' % (crv), normal=(0, 1, 0), degree=1, constructionHistory=True)[0] zroCvPos = cmds.pointPosition('%s.cv[0]' % (crv), world=True) cmds.xform(profile, ws=True, t=zroCvPos) # profile scale grp scaleGrp = cmds.duplicate(profile, po=True, n='%s_scale' % (profile)) cmds.makeIdentity(scaleGrp, apply=True) cmds.parent(profile, scaleGrp) # set to profile rotation 45 degree as default cmds.setAttr('%s.rotateY' % (profile), 45) # rebuild crv # cls.rebuildCrv(crv, 8) # extrude extrRslt = cmds.extrude(profile, crv, ch=True, rn=False, et=2, po=1, ucp=1, fpt=1, upn=1, rsp=1, n='%s_poly' % (crv)) polyTubeLs.append(extrRslt[0]) # hide curve and profile cmds.hide(profile) cmds.select(polyTubeLs)
def extrude(name = "defaultName", *args): print "starting extrude" sel = cmds.ls(sl=True) guideCrv = sel[0] if len(sel)>1: profileCrv = cmds.duplicate(sel[1], name="{}_profile_CRV".format(name))[0] else: profileCrv = cmds.circle(r=1, normal = (0, 1, 0), name="{}_profile_CRV".format(name), ch=False)[0] if len(sel) == 3: capRig = sel[2] else: capRig = "" if len(sel) > 3: return capAxis = "y" capUp = "z" # upLoc = cmds.spaceLocator(name = "{}_upLoc".format(name))[0] ctrl = rig.createControl(type="sphere", name="{}_CTRL".format(name), color="blue") ctrlGrp = cmds.group(empty=True, name="{}_path_GRP".format(name)) capGrp = cmds.group(empty=True, name="{}_cap_GRP".format(name)) deadGrp = cmds.group(empty=True, name="{}_noInherit_GRP".format(name)) if capRig: cmds.parent(capRig, capGrp) cmds.parent(deadGrp, ctrlGrp) cmds.parent(ctrl, ctrlGrp) # add attrs to control cmds.addAttr(ctrl, ln="__xtraAttrs__", nn="__xtraAttrs__", at="bool", k=True) cmds.setAttr("{}.__xtraAttrs__".format(ctrl), l=True) cmds.addAttr(ctrl, ln="alongPath", at="float", min=0, max=100, k=True, dv=100.0) cmds.setAttr("{}.alongPath".format(ctrl), 100) cmds.addAttr(ctrl, ln="reverseNormals", at="long", min=0, max=1, k=True) cmds.addAttr(ctrl, ln="capVisibility", at="long", min=0, max=1, k=True) cmds.setAttr("{}.capVisibility".format(ctrl), 1) cmds.addAttr(ctrl, ln="capWidth", at="float", k=True, min=.01, max=2.0, dv=1.0) cmds.addAttr(ctrl, ln="capHeight", at="float", k=True, min=.01, max=2.0, dv=1.0) cmds.addAttr(ctrl, ln="profileWidth", at="float", k=True, min=.001, max=3, dv=1.0) # driver attrs cmds.addAttr(ctrl, ln="textureRepeatMult", at="float", min = 0.01, dv= 1.0, k=True) cmds.addAttr(ctrl, ln="prmHolder", at="float", k=True) cmds.addAttr(ctrl, ln="rptHolder", at="float", k=True) # cmds.addAttr(ctrl, ln="repeatMult", at="message", k=True) # cmds.addAttr(ctrl, ln="parameterMult", at ="message", k=True) # connect mult to path mult = cmds.shadingNode("multiplyDivide", asUtility=True, name="{}_paraMult".format(name)) cmds.connectAttr("{}.alongPath".format(ctrl), "{}.input1X".format(mult)) cmds.setAttr("{}.input2X".format(mult), 0.01) cmds.connectAttr("{}.profileWidth".format(ctrl), "{}.scaleX".format(profileCrv)) cmds.connectAttr("{}.profileWidth".format(ctrl), "{}.scaleZ".format(profileCrv)) # reverse for normals reverse = cmds.shadingNode("reverse", asUtility=True, name="{}_reverse".format(name)) cmds.connectAttr("{}.reverseNormals".format(ctrl), "{}.inputX".format(reverse)) # cap and texture attrs and nodes cmds.connectAttr("{}.capVisibility".format(ctrl), "{}.v".format(capGrp)) repeatMult = cmds.shadingNode("multiplyDivide", asUtility=True, name="{}_RptMult".format(name)) cmds.connectAttr("{}.outputX".format(mult), "{}.input1X".format(repeatMult)) cmds.connectAttr("{}.textureRepeatMult".format(ctrl), "{}.input2X".format(repeatMult)) # cmds.connectAttr("{}.message".format(repeatMult), "{}.repeatMult".format(ctrl)) # cmds.connectAttr("{}.message".format(mult), "{}.parameterMult".format(ctrl)) cmds.connectAttr("{}.outputX".format(repeatMult), "{}.rptHolder".format(ctrl)) cmds.connectAttr("{}.outputX".format(mult), "{}.prmHolder".format(ctrl)) cmds.setAttr("{}.prmHolder".format(ctrl), l=True) cmds.setAttr("{}.rptHolder".format(ctrl), l=True) cmds.connectAttr("{}.capWidth".format(ctrl), "{}.scaleX".format(capGrp)) cmds.connectAttr("{}.capWidth".format(ctrl), "{}.scaleZ".format(capGrp)) cmds.connectAttr("{}.capHeight".format(ctrl), "{}.scaleY".format(capGrp)) # position control at start of curve startPos = cmds.pointOnCurve(guideCrv, parameter = 0, position = True) cmds.xform(ctrlGrp, ws=True, t=startPos) # cmds.xform(upLoc, ws=True, t=(startPos[0], startPos[1]+3.0, startPos[2])) moPath = cmds.pathAnimation(capGrp, guideCrv, fractionMode=True, follow=True, followAxis=capAxis, upAxis=capUp, worldUpType="scene", startTimeU=0.0, endTimeU=100.0) moPathAnimAttr = cmds.listConnections("{}.uValue".format(moPath), d=False, p=True)[0] start, end = getSliderRange() current = cmds.currentTime(q=True) cmds.currentTime(start) pPos = cmds.xform(capGrp, q=True, ws=True, rp=True) pRot = cmds.xform(capGrp, q=True, ws=True, ro=True) cmds.xform(profileCrv, ws=True, t=pPos) cmds.xform(profileCrv, ws=True, ro=pRot) cmds.currentTime(current) # extrude the curve extr = cmds.extrude(profileCrv, guideCrv, ch=True, range=True, polygon=True, extrudeType=2, useComponentPivot=True, fixedPath=True, useProfileNormal=True, reverseSurfaceIfPathReversed=True) extrGeo, extrNode = extr[0], extr[1] normal = cmds.polyNormal(extrGeo, normalMode=4, userNormalMode=0, ch=1)[0] cmds.connectAttr("{}.outputX".format(reverse), "{}.normalMode".format(normal)) # get extrude connections connects = cmds.listConnections(extrNode) profNode, pathNode, tessNode = connects[0], connects[1], connects[2] # connect up stuff to extrusion cmds.connectAttr("{}.outputX".format(mult), "{}.maxValue".format(pathNode)) cmds.parent(guideCrv, ctrl) cmds.setAttr("{}.inheritsTransform".format(deadGrp), 0) cmds.parent(extrGeo, deadGrp) cmds.parent(profileCrv, deadGrp) cmds.setAttr("{}.v".format(profileCrv), 0) cmds.parent(capGrp, deadGrp) # motion path stuff cmds.delete(moPathAnimAttr.partition(".")[0]) cmds.connectAttr("{}.outputX".format(mult), "{}.uValue".format(moPath)) # reference # extrude -ch true -rn true -po 1 -et 2 -ucp 1 -fpt 1 -upn 1 -rotation 0 -scale 1 -rsp 1 "nurbsCircle1" "curve4" ; print "ending extrude"
def _buildSideSplashEmitter(name='', boatName='', splashParticleName=[], boatIntersectCurveShape='', sideAnimatable='', presetName=None): """ New builder for sideSplash nParticle Emitter Checks if the NPARTICLE_EMITTLERS_hrc exists or not too @param name: The name of the new emitter @param splashParticleName: List of the names of nParticleShape nodes to connect to the emitter @param boatIntersectCurveShape: The name of the intersection curve to emit from. @type name: String @type splashParticleName: List @type boatIntersectCurveShape: String """ if not cmds.objExists('nPARTICLE_EMITTERS_hrc'): cmds.group(n='nPARTICLE_EMITTERS_hrc', em=True) debug(None, method='_buildSideSplashEmitter', message='name: %s' % name, verbose=False) # Get base flat surface lineCurve = cmds.curve(name='%s_extrudeCurve' % name, degree=1, point=[(-0.01, 0, 0), (0.01, 0, 0)]) flatSurface = cmds.extrude(lineCurve, boatIntersectCurveShape, name='%s_flatSurface' % name, constructionHistory=True, range=False, polygon=0, useComponentPivot=1, fixedPath=True, useProfileNormal=True, extrudeType=2, reverseSurfaceIfPathReversed=True)[0] cmds.rebuildSurface(flatSurface, constructionHistory=True, replaceOriginal=True, rebuildType=0, endKnots=1, keepCorners=False, spansU=1, degreeU=1, spansV=100, degreeV=3) # Offset upwards curve from surface offsetUp = cmds.offsetCurve('%s.u[0.5]' % flatSurface, name='%s_offsetUp' % name, distance=0, constructionHistory=True, range=0, subdivisionDensity=1)[0] cmds.rebuildCurve(offsetUp, constructionHistory=False, replaceOriginal=True, end=1, keepRange=0, keepControlPoints=True, degree=1) cmds.setAttr('%s.translateY' % offsetUp, 0.01) # Offset from upwards curve with distance and translate down to get the 45 degree angle offset_distance = -0.01 offsetOut = cmds.offsetCurve(offsetUp, name='%s_offsetOut' % name, distance=offset_distance, constructionHistory=True, range=0, subdivisionDensity=1)[0] cmds.setAttr('%s.translateY' % offsetOut, offset_distance) # Finally, loft a non-flipping surface solution (45 degree angle of the boat) noFlipSurface = cmds.loft(offsetUp, offsetOut, degree=1, constructionHistory=True, range=0, polygon=0, sectionSpans=1)[0] noFlipSurface = cmds.rename(noFlipSurface, '%s_noFlipSurface' % name) ## Build the emitter emitter = cmds.emitter(noFlipSurface, name='%s_emitter' % name, type='surface') # Create closestPointOnSurface for acceleration expression where front more acceleration cPoS = cmds.createNode('closestPointOnSurface', name='%s_cPoS' % name) cmds.connectAttr('%s.worldSpace' % noFlipSurface, '%s.inputSurface' % cPoS) ## Build the emitter group if it doesn't already exist emitterGroup = '%s_hrc' % name if not cmds.objExists(emitterGroup): cmds.group(lineCurve, flatSurface, offsetUp, offsetOut, noFlipSurface, emitter[0], n=emitterGroup) debug(None, method='_buildSideSplashEmitter', message='emitterName: %s' % emitter[1], verbose=False) ## Check if a custom preset has been assigned via the func flags for the emitter, if not use the default preset... if presetName: pathToPreset = '%s/%s' % (CONST.EMITTERBASEPRESETPATH, presetName) debug(None, method='_buildSideSplashEmitter', message='pathToPreset: %s' % pathToPreset, verbose=False) mel.eval('applyPresetToNode "%s" "" "" "%s" 1;' % (emitter[1], pathToPreset)) ## Now parent it try: cmds.parent(emitterGroup, 'nPARTICLE_EMITTERS_hrc') except: pass ## Connect the emitter to the particles debug(None, method='_buildSideSplashEmitter', message='Connected %s: %s' % (splashParticleName, emitter[1]), verbose=False) for each in splashParticleName: _connect_NParticleShape_to_NParticleEmitter(particleShapeNode=each, emitter=emitter[1]) ## Now do the expression for the side emitter if 'IntersectCurveRight' in emitter[1]: direction = 'R' else: direction = 'L' expStringList = [ 'float $minSpeed = %s.minSpeed;\n' % sideAnimatable, 'float $maxSpeed = %s.maxSpeed;\n' % sideAnimatable, 'float $speed = %s:world_ctrl.speed;\n' % boatName, 'float $curve = smoothstep($minSpeed, $maxSpeed, $speed);\n', 'float $rateMuliplier = %s.rateMultiplier%s;\n' % (sideAnimatable, direction), 'float $splashMaxSpeed = %s.splashMaxSpeed%s;\n' % (sideAnimatable, direction), '\n', 'if (%s.useSpeed == 1)\n' % sideAnimatable, '{\n\t', '%s.rate = $rateMuliplier * $curve;\n' % emitter[1], '\n\t\t', 'float $emitterSpeed = $splashMaxSpeed * $curve;\n\t\t', 'if ($emitterSpeed == 0)\n\t\t', '{\n\t\t\t', '$emitterSpeed = 0.1;\n\t\t', '}\n\t\t', '%s.speed = $emitterSpeed;\n' % emitter[1], '}\n', 'else\n', '{\n\t', '%s.rate = $rateMuliplier;\n\t' % emitter[1], '%s.speed = $splashMaxSpeed;\n' % emitter[1], '}\n', ] ## Check if the expression already exists in the scene, if so delete it utils.checkExpressionExists('%s_sideSplashEmitter' % boatName) ## Build new expression cmds.expression(emitter[1], n='%s_sideSplashEmitter' % emitter[1], string=utils.processExpressionString(expStringList)) ## Connect some attributes if not cmds.isConnected('%s.normalSpeed%s' % (sideAnimatable, direction), '%s.normalSpeed' % emitter[1]): cmds.connectAttr('%s.normalSpeed%s' % (sideAnimatable, direction), '%s.normalSpeed' % emitter[1]) if not cmds.isConnected('%s.randomSpeed%s' % (sideAnimatable, direction), '%s.speedRandom' % emitter[1]): cmds.connectAttr('%s.randomSpeed%s' % (sideAnimatable, direction), '%s.speedRandom' % emitter[1]) return cPoS
def drawBranch(self, iteration, cX, cY, cZ, nrX, nrY, nrZ, radius, length): if (iteration < self.branches): iteration = iteration + 1 #Draw circle and extrude based on parameters shape = mc.circle(nr=(nrX, nrY, nrZ), c=(cX, cY, cZ), r=radius) poly = mc.extrude(shape, et=0, d=(nrX, nrY, nrZ), l=length) mc.group(poly, parent=self.grp) #Delete the base circle and keep the cylinder mc.delete(shape) #direction vector to grow vector = MVector(nrX, nrY, nrZ) vector.normalize() cX = cX + (length * vector.x) cY = cY + (length * vector.y) cZ = cZ + (length * vector.z) randX = r.randint(0, 1) * 2 - 1 randY = r.randint(0, 1) * 2 - 1 randZ = r.randint(0, 1) * 2 - 1 #Random direction vector #For X, Y, Z, ( -1 or 1 )*angle + (randint from -angleVariance to +angleVariance) nrX = nrX + ((self.angle * randX) + random.randint( 0, self.angleVariance * 2) - self.angleVariance) / 100.0 nrY = nrY + ((self.angle * randY) + random.randint( 0, self.angleVariance * 2) - self.angleVariance) / 100.0 nrZ = nrZ + ((self.angle * randZ) + random.randint( 0, self.angleVariance * 2) - self.angleVariance) / 100.0 #Length and Radius based on factor + (randint from -variance to +variance) length = length * ( self.lengthFactor + (random.randint(0, self.lengthVariance * 2 * 100) / 100.0) - self.lengthVariance) radius = radius * ( self.radiusFactor + (random.randint(0, self.radiusVariance * 2 * 100) / 100.0) - self.radiusVariance) #Draw first branch self.drawBranch(iteration, cX, cY, cZ, nrX, nrY, nrZ, radius, length) #Use opposite base angle from previous branch nrX = nrX + ((self.angle * randX * -1) + random.randint( 0, self.angleVariance * 2) - self.angleVariance) / 100.0 nrY = nrY + ((self.angle * randY * -1) + random.randint( 0, self.angleVariance * 2) - self.angleVariance) / 100.0 nrZ = nrZ + ((self.angle * randZ * -1) + random.randint( 0, self.angleVariance * 2) - self.angleVariance) / 100.0 length = length * ( self.lengthFactor + (random.randint(0, self.lengthVariance * 2 * 100) / 100.0) - self.lengthVariance) radius = radius * ( self.radiusFactor + (random.randint(0, self.radiusVariance * 2 * 100) / 100.0) - self.radiusVariance) #Draw second branch self.drawBranch(iteration, cX, cY, cZ, nrX, nrY, nrZ, radius, length)
def build(self): self.addPinParent() self.addAttrLimb(ln='noStretch', at='float', min=0, max=1, dv=0, k=True, s=1) self.addAttrLimb(ln='slideAlong', at='float', min=-1, max=1, dv=0, k=True, s=1) jointList = mpJoint.getJointList(self.startJoint, self.endJoint) if len(jointList) < 2: raise RuntimeError( 'NurbsStrip requires at least 2 joints in chain. Got %s' % len(jointList)) #Create NURBS strip by making curves along joints, and a cross section crv, then extruding crv = mpNurbs.curveFromNodes(jointList) crossCurve = cmds.curve(d=1, p=[(0, 0, -0.5 * self.stripWidth), (0, 0, 0.5 * self.stripWidth)], k=(0, 1)) cmds.select([crossCurve, crv], r=1) surf = cmds.extrude(ch=False, po=0, et=2, ucp=1, fpt=1, upn=1, rotation=0, scale=1, rsp=1)[0] cmds.delete([crv, crossCurve]) self.name.desc = 'driverSurf' surf = cmds.rename(surf, self.name.get()) cmds.parent(surf, self.noXform) #Rebuild strip to proper number of spans cmds.rebuildSurface(surf, ch=0, rpo=1, rt=0, end=1, kr=0, kcp=0, kc=1, sv=self.numSpans, su=0, du=1, tol=0.01, fr=0, dir=2) #make live curve on surface down the middle #this is used later for noStretch curvMaker = cmds.createNode('curveFromSurfaceIso', n=surf + "CurveIso") cmds.setAttr(curvMaker + ".isoparmValue", 0.5) cmds.setAttr(curvMaker + ".isoparmDirection", 1) cmds.connectAttr(surf + ".worldSpace[0]", curvMaker + ".inputSurface") offsetCrvShp = cmds.createNode("nurbsCurve", n=crv + "_driverSurfCrvShape") offsetCrv = cmds.listRelatives(p=1)[0] offsetCrv = cmds.rename(offsetCrv, crv + "_driverSurfCrv") cmds.connectAttr(curvMaker + ".outputCurve", offsetCrvShp + ".create") cmds.parent(offsetCrv, self.noXform) #Measure curve length and divide by start length #to get a normalized value that is useful later to control stretch crvInfo = cmds.createNode('curveInfo', n=offsetCrv + "Info") cmds.connectAttr(offsetCrv + ".worldSpace[0]", crvInfo + ".ic") arcLength = cmds.getAttr(crvInfo + ".al") stretchAmountNode = cmds.createNode('multiplyDivide', n=offsetCrv + "Stretch") cmds.setAttr(stretchAmountNode + ".op", 2) #divide cmds.setAttr(stretchAmountNode + ".input1X", arcLength) cmds.connectAttr(crvInfo + ".al", stretchAmountNode + ".input2X") #Stretch Blender blends start length with current length #and pipes it back into stretchAmoundNode's startLength, so user can turn #stretch behavior on or off stretchBlender = cmds.createNode('blendColors', n=offsetCrv + "StretchBlender") cmds.setAttr(stretchBlender + ".c1r", arcLength) cmds.connectAttr(crvInfo + ".al", stretchBlender + ".c2r") cmds.connectAttr(stretchBlender + ".opr", stretchAmountNode + ".input1X") cmds.connectAttr(self.limbNode + ".noStretch", stretchBlender + ".blender") #attach joints to surface closestPoint = cmds.createNode('closestPointOnSurface', n='tempClose') cmds.connectAttr(surf + ".worldSpace[0]", closestPoint + ".inputSurface") for idx, jnt in enumerate(jointList): self.name.desc = 'jnt%02dOffset' % idx locator = cmds.spaceLocator(n=self.name.get())[0] cmds.setAttr(locator + '.localScale', self.stripWidth, self.stripWidth, self.stripWidth) cmds.parent(locator, self.noXform) #Use closest point to to find jnt's percent along the curve cmds.setAttr(closestPoint + '.ip', *cmds.xform(jnt, q=True, t=True, ws=True)) percentage = cmds.getAttr(closestPoint + '.r.v') #attach to surface posNode, aimCnss, moPath, slider = self.attachObjToSurf( locator, surf, offsetCrv, stretchAmountNode, percentage) cmds.connectAttr(self.limbNode + ".slideAlong", slider + ".i2") cmds.parentConstraint(locator, jnt, mo=True) cmds.delete(closestPoint) #add controls.These drive new joints which skinCluster the NURBS strips stripJoints = [] stripJointParent = cmds.createNode('transform', n=crv + "_stripJoints", p=self.noXform) ctrlParent = cmds.createNode('transform', n=crv + "_Ctrls", p=self.pinParent) cmds.xform(ctrlParent, ws=True, m=[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]) prevCtrl = None for i in range(self.numCtrls): ctrlXform = mpMath.Transform(jointList[0]) zero, ctrl = self.addCtrl('Ctrl%02d' % i, type='FK', shape='box', parent=ctrlParent, xform=ctrlXform) ctrlXform.scale(0.8, 0.8, 0.8) tZero, tCtrl = self.addCtrl('TweakCtrl%02d' % i, type='FK', shape='cross', parent=ctrl, xform=ctrlXform) #Make the new joint for the control to drive cmds.select(clear=True) self.name.desc = 'StripJnt%02d' % i jnt = cmds.joint(p=(0, 0, 0), n=self.name.get()) cmds.parentConstraint(tCtrl, jnt, mo=False) #briefly attach ctrls to strip to align them percentage = float(i) / (self.numCtrls - 1.0) if i > 0 and i < self.numCtrls - 1: percentage = self.uMin + (percentage * (self.uMax - self.uMin)) cmds.delete( self.attachObjToSurf(zero, surf, offsetCrv, stretchAmountNode, percentage)) cmds.parent(jnt, stripJointParent) stripJoints.append(jnt) if prevCtrl: cmds.parent(zero, prevCtrl) mpRig.addPickParent(ctrl, prevCtrl) prevCtrl = ctrl #skin strip to controls #Can get some different behavior by chaning the strip's weights #or perhaps using dual quat. mode on the skinCluster skinObjs = stripJoints + [surf] cmds.skinCluster( skinObjs, bindMethod=0, #closest Point sm=0, #standard bind method ih=True, #ignore hierarchy )
cmds.addAttr(ctrl, ln='param', min=0, max=1, dv=param, k=True) cmds.addAttr(ctrl, ln='bulge', min=-1, dv=0, k=True) cmds.connectAttr(ctrl + '.param', locs[i] + '.param[' + str(ind) + ']', f=True) cmds.connectAttr(ctrl + '.bulge', wire + '.wireLocatorEnvelope[' + str(ind) + ']', f=True) def buildTube(crv, profile = None, addCage = False, prefix = None): """ """ # Nurbs Tube cmds.extrude( ch=True, rn=False, po=0, et=2, ucp=1, fpt=1, upn=1, rotation=0, scale=1, rsp=1 ) # Polygon Tube cmds.extrude( ch=True, rn=False, po=1, et=2, ucp=1, fpt=1, upn=1,
def _buildSideSplashEmitter(name = '', boatName = '', splashParticleName = [], boatIntersectCurveShape = '', sideAnimatable = '', presetName = None): """ New builder for sideSplash nParticle Emitter Checks if the NPARTICLE_EMITTLERS_hrc exists or not too @param name: The name of the new emitter @param splashParticleName: List of the names of nParticleShape nodes to connect to the emitter @param boatIntersectCurveShape: The name of the intersection curve to emit from. @type name: String @type splashParticleName: List @type boatIntersectCurveShape: String """ if not cmds.objExists('nPARTICLE_EMITTERS_hrc'): cmds.group(n = 'nPARTICLE_EMITTERS_hrc', em = True) debug(None, method = '_buildSideSplashEmitter', message = 'name: %s' % name, verbose = False) # Get base flat surface lineCurve = cmds.curve( name = '%s_extrudeCurve' % name, degree = 1, point = [(-0.01, 0, 0), (0.01, 0, 0)] ) flatSurface = cmds.extrude(lineCurve, boatIntersectCurveShape, name = '%s_flatSurface' % name, constructionHistory = True, range = False, polygon = 0, useComponentPivot = 1, fixedPath = True, useProfileNormal = True, extrudeType = 2, reverseSurfaceIfPathReversed = True)[0] cmds.rebuildSurface(flatSurface, constructionHistory = True, replaceOriginal = True, rebuildType = 0, endKnots = 1, keepCorners = False, spansU = 1, degreeU = 1, spansV = 100, degreeV = 3) # Offset upwards curve from surface offsetUp = cmds.offsetCurve('%s.u[0.5]' % flatSurface, name = '%s_offsetUp' % name, distance = 0, constructionHistory = True, range = 0, subdivisionDensity = 1)[0] cmds.rebuildCurve(offsetUp, constructionHistory = False, replaceOriginal = True, end = 1, keepRange = 0, keepControlPoints = True, degree = 1) cmds.setAttr('%s.translateY' % offsetUp, 0.01) # Offset from upwards curve with distance and translate down to get the 45 degree angle offset_distance = -0.01 offsetOut = cmds.offsetCurve(offsetUp, name = '%s_offsetOut' % name, distance = offset_distance, constructionHistory = True, range = 0, subdivisionDensity = 1)[0] cmds.setAttr('%s.translateY' % offsetOut, offset_distance) # Finally, loft a non-flipping surface solution (45 degree angle of the boat) noFlipSurface = cmds.loft(offsetUp, offsetOut, degree = 1, constructionHistory = True, range = 0, polygon = 0, sectionSpans = 1)[0] noFlipSurface = cmds.rename(noFlipSurface, '%s_noFlipSurface' % name) ## Build the emitter emitter = cmds.emitter(noFlipSurface, name = '%s_emitter' % name, type = 'surface') # Create closestPointOnSurface for acceleration expression where front more acceleration cPoS = cmds.createNode('closestPointOnSurface', name = '%s_cPoS' % name) cmds.connectAttr('%s.worldSpace' % noFlipSurface, '%s.inputSurface' % cPoS) ## Build the emitter group if it doesn't already exist emitterGroup = '%s_hrc' % name if not cmds.objExists(emitterGroup): cmds.group(lineCurve, flatSurface, offsetUp, offsetOut, noFlipSurface, emitter[0], n = emitterGroup) debug(None, method = '_buildSideSplashEmitter', message = 'emitterName: %s' % emitter[1], verbose = False) ## Check if a custom preset has been assigned via the func flags for the emitter, if not use the default preset... if presetName: pathToPreset = '%s/%s' %(CONST.EMITTERBASEPRESETPATH, presetName) debug(None, method = '_buildSideSplashEmitter', message = 'pathToPreset: %s' % pathToPreset, verbose = False) mel.eval( 'applyPresetToNode "%s" "" "" "%s" 1;' %(emitter[1], pathToPreset) ) ## Now parent it try: cmds.parent(emitterGroup, 'nPARTICLE_EMITTERS_hrc') except: pass ## Connect the emitter to the particles debug(None, method = '_buildSideSplashEmitter', message = 'Connected %s: %s' % (splashParticleName, emitter[1]), verbose = False) for each in splashParticleName: _connect_NParticleShape_to_NParticleEmitter(particleShapeNode = each, emitter = emitter[1]) ## Now do the expression for the side emitter if 'IntersectCurveRight' in emitter[1]: direction = 'R' else: direction = 'L' expStringList = [ 'float $minSpeed = %s.minSpeed;\n' % sideAnimatable, 'float $maxSpeed = %s.maxSpeed;\n' % sideAnimatable, 'float $speed = %s:world_ctrl.speed;\n' % boatName, 'float $curve = smoothstep($minSpeed, $maxSpeed, $speed);\n', 'float $rateMuliplier = %s.rateMultiplier%s;\n' %(sideAnimatable, direction), 'float $splashMaxSpeed = %s.splashMaxSpeed%s;\n' %(sideAnimatable, direction), '\n', 'if (%s.useSpeed == 1)\n' % sideAnimatable, '{\n\t', '%s.rate = $rateMuliplier * $curve;\n' % emitter[1], '\n\t\t', 'float $emitterSpeed = $splashMaxSpeed * $curve;\n\t\t', 'if ($emitterSpeed == 0)\n\t\t', '{\n\t\t\t', '$emitterSpeed = 0.1;\n\t\t', '}\n\t\t', '%s.speed = $emitterSpeed;\n' % emitter[1], '}\n', 'else\n', '{\n\t', '%s.rate = $rateMuliplier;\n\t' % emitter[1], '%s.speed = $splashMaxSpeed;\n' % emitter[1], '}\n', ] ## Check if the expression already exists in the scene, if so delete it utils.checkExpressionExists('%s_sideSplashEmitter' % boatName) ## Build new expression cmds.expression(emitter[1], n = '%s_sideSplashEmitter' % emitter[1], string = utils.processExpressionString(expStringList)) ## Connect some attributes if not cmds.isConnected('%s.normalSpeed%s' %(sideAnimatable, direction), '%s.normalSpeed' % emitter[1]): cmds.connectAttr('%s.normalSpeed%s' %(sideAnimatable, direction), '%s.normalSpeed' % emitter[1]) if not cmds.isConnected('%s.randomSpeed%s' %(sideAnimatable, direction), '%s.speedRandom' % emitter[1]): cmds.connectAttr('%s.randomSpeed%s' %(sideAnimatable, direction), '%s.speedRandom' % emitter[1]) return cPoS
def execute(self): sx = self.sx sy = self.sy sdv = self.sdv sdu = self.sdu tap = self.tap degs = self.degs subCurve = self.subCurve clean = self.clean do_uvs = self.do_uvs rbc = self.rbc cTol = self.cTol cSubd = self.cSubd if cmds.checkBox(self.aUACCB, q=True, v=True): useAltShape = True else: useAltShape = False multSel = cmds.ls(sl=True, fl=True, ap=True) if cmds.objectType(multSel[0]) == 'mesh': thisIsAMesh = True else: thisIsAMesh = False # Select curve type to extrude along - convert and store for x in multSel: print x if thisIsAMesh != True: cmds.select(x) else: cmds.select(multSel) objSel = cmds.ls(sl=True, fl=True, ap=True) if self.ko == 1: dupObj = cmds.duplicate(objSel) objSel = dupObj if len(objSel) > 1: print objSel if degs == 0: curveDg = cmds.promptDialog( t='Enter Degrees:', m='Enter Degrees - ie. 1 for linear, 3 for curved') objSel = cmds.polyToCurve(f=2, dg=int( cmds.promptDialog(q=True, tx=True))) else: objSel = cmds.polyToCurve(f=2, dg=int(degs), n='%s_curve' % objSel[0].split('.')[0]) else: objType = cmds.listRelatives(objSel[0], f=True) if cmds.objectType( objType[0]) != 'nurbsCurve' and cmds.objectType( objType[0]) != 'bezierCurve': cmds.error( 'Select the nurbs curve first, then the object to align' ) if cmds.objectType(objType[0]) == 'bezierCurve': mm.eval("bezierCurveToNurbs;") # Create a nurbs curve for the extrusion if useAltShape: nurbsCir = self.objToUse else: nurbsCir = cmds.circle(n='extrudeCircle', d=3, r=1, nr=(0, 0, 1), sw=360, ch=True, s=8) objCV = cmds.ls('%s.ep[*]' % objSel[0], fl=True) noOfCV = len(objCV) firstCV = 0 lastCV = noOfCV - 1 cvNumberToUse = firstCV # Rebuild the curve to help with uniformity if self.rev == 1: cmds.reverseCurve(objSel[0], ch=0, rpo=1) if rbc == 1: try: cmds.rebuildCurve(objSel[0], ch=0, rpo=1, rt=4, end=1, kr=0, kcp=0, kep=1, kt=0, s=cSubd, d=3, tol=cTol) cmds.rebuildCurve(objSel[0], ch=0, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=cSubd, d=3, tol=cTol) except: cmds.warning( 'Tolerance for rebuild likely to low, try a higher value or turn Rebuild Curve off' ) if do_uvs == 1: objShape = cmds.listRelatives(objSel[0], c=True, type='shape') mInfo = cmds.shadingNode('curveInfo', n='cMeasure', asUtility=True) cmds.connectAttr('%s.local' % objShape[0], '%s.inputCurve' % mInfo) curveLength = cmds.getAttr('%s.arcLength' % mInfo) cmds.delete(mInfo) self.uvRatio = float( (((sx * sy) * 2.0) * math.pi) / curveLength) print "uvRatio: " + str(self.uvRatio) # Create a tangent contraint to position nurbs circle to the first cv cvPos = cmds.xform('%s.ep[%d]' % (objSel[0], cvNumberToUse), query=True, ws=True, t=True) cmds.xform(nurbsCir[0], ws=True, t=(cvPos[0], cvPos[1], cvPos[2])) fastCon = cmds.tangentConstraint(objSel[0], nurbsCir[0], aim=(0, 0, 1)) cmds.delete(fastCon[0]) # Extrude along curve and set attributes pipeExt = cmds.extrude(nurbsCir[0], objSel[0], n='%s_pipe' % objSel[0], ch=True, rn=subCurve, po=1, et=2, ucp=1, fpt=1, upn=1, rotation=0, scale=1, rsp=1) pipeTes = cmds.listConnections(pipeExt[1], type='nurbsTessellate') if subCurve != 0: pipeSubCurve = cmds.listConnections(pipeExt[1], type='subCurve') cmds.setAttr('%s.format' % pipeTes[0], 2) cmds.setAttr('%s.polygonType' % pipeTes[0], 1) cmds.setAttr('%s.uType' % pipeTes[0], 2) cmds.setAttr('%s.vType' % pipeTes[0], 2) cmds.setAttr('%s.vNumber' % pipeTes[0], sdv) cmds.setAttr('%s.uNumber' % pipeTes[0], sdu) # Add attributes if clean == 0: cmds.addAttr(pipeExt[0], ln='________', k=True) cmds.setAttr('%s.________' % pipeExt[0], l=True) cmds.addAttr(pipeExt[0], ln='Ext_ScaleX', k=True, dv=sx) cmds.addAttr(pipeExt[0], ln='Ext_ScaleY', k=True, dv=sy) cmds.connectAttr('%s.Ext_ScaleX' % pipeExt[0], '%s.scaleX' % nurbsCir[0]) cmds.connectAttr('%s.Ext_ScaleY' % pipeExt[0], '%s.scaleY' % nurbsCir[0]) cmds.addAttr(pipeExt[0], ln='Ext_DivisionV', at='short', k=True, dv=sdv) cmds.connectAttr('%s.Ext_DivisionV' % pipeExt[0], '%s.vNumber' % pipeTes[0]) cmds.addAttr(pipeExt[0], ln='Ext_DivisionU', at='short', k=True, dv=sdu) cmds.connectAttr('%s.Ext_DivisionU' % pipeExt[0], '%s.uNumber' % pipeTes[0]) if subCurve != 0: cmds.addAttr(pipeExt[0], ln='Ext_Length', k=True, dv=1, max=1, min=0) cmds.connectAttr('%s.Ext_Length' % pipeExt[0], '%s.maxValue' % pipeSubCurve[1]) cmds.addAttr(pipeExt[0], ln='Ext_Taper', k=True, dv=tap, min=0) cmds.connectAttr('%s.Ext_Taper' % pipeExt[0], '%s.scale' % pipeExt[1]) cmds.addAttr(pipeExt[0], ln='Ext_Twist', k=True, dv=1) cmds.connectAttr('%s.Ext_Twist' % pipeExt[0], '%s.rotation' % pipeExt[1]) cmds.addAttr(pipeExt[0], ln='Ext_ComponentPivot', k=True, dv=1) cmds.connectAttr('%s.Ext_ComponentPivot' % pipeExt[0], '%s.useComponentPivot' % pipeExt[1]) curveGrpNode = cmds.createNode('transform', n='pipeCurves') cmds.parent(nurbsCir, curveGrpNode) cmds.parent(objSel, curveGrpNode) cmds.setAttr('%s.inheritsTransform' % curveGrpNode, 0) cmds.setAttr('%s.visibility' % curveGrpNode, 1) cmds.parent(curveGrpNode, pipeExt[0]) cmds.select(pipeExt[0]) if do_uvs == 1: cmds.polyLayoutUV(ps=0.2) cmds.polyEditUV(sv=1, su=self.uvRatio) cmds.polyEditUV(sv=0.95, su=0.95) cmds.select(pipeExt[0]) CentreUVs() if clean == 1: cmds.delete(ch=True) cmds.delete(curveGrpNode) cmds.select(pipeExt[0]) if thisIsAMesh == True: print 'hello' break
def rigFromCurve(self,crv,numSpans=8,numJoints=10,numCtrls=5,stripWidth = 1.0,ctrlWidth=2.0,geo=None,uMin=0.0,uMax=1.0): '''make a cable rig from the given curve numSpans = number of spans in Nurbs strip numJoints = number of joints riding on nurbs strip numCtrls = number of controls to make stripWidth = width of nurbs strip (can make it easier to paint weights if wider) ctrlWidth = size of ctrls ''' shapes = cmds.listRelatives(crv,s=1) crvShape = shapes[0] #Make rig top nulls to parent stuff under topNull = cmds.createNode('transform',n=crv + "_Rig") hiddenStuff = cmds.createNode('transform',n=crv + "_NOTOUCH",p=topNull) cmds.setAttr(hiddenStuff + ".inheritsTransform", 0) cmds.setAttr(hiddenStuff + ".visibility", 0) cmds.addAttr(topNull, ln="stretchAmount",dv=1.0,min=0,max=1) cmds.addAttr(topNull, ln='slideAmount',dv=0.0) #make nurbs strip using extrude crossCurve = cmds.curve(d=1,p=[(0,0,-0.5 * stripWidth),(0,0,0.5 * stripWidth)],k=(0,1)) cmds.select([crossCurve,crv],r=1) surf = cmds.extrude(ch=False,po=0,et=2,ucp=1,fpt=1,upn=1,rotation=0,scale=1,rsp=1)[0] cmds.delete(crossCurve) surf = cmds.rename(surf, crv + "_driverSurf") cmds.parent(surf,hiddenStuff) #Rebuild strip to proper number of spans cmds.rebuildSurface(surf,ch=0,rpo=1,rt=0,end=1,kr=0,kcp=0,kc=1,sv=numSpans,su=0,du=1,tol=0.01,fr=0,dir=2) #make live curve on surface down the middle #this is used later for noStretch curvMaker = cmds.createNode('curveFromSurfaceIso', n = surf+"CurveIso") cmds.setAttr(curvMaker + ".isoparmValue", 0.5) cmds.setAttr(curvMaker + ".isoparmDirection", 1) cmds.connectAttr(surf + ".worldSpace[0]", curvMaker + ".inputSurface") offsetCrvShp = cmds.createNode("nurbsCurve", n=crv + "_driverSurfCrvShape") offsetCrv = cmds.listRelatives(p=1)[0] offsetCrv = cmds.rename(offsetCrv,crv + "_driverSurfCrv") cmds.connectAttr(curvMaker + ".outputCurve", offsetCrvShp + ".create") cmds.parent(offsetCrv, hiddenStuff) #Measure curve length and divide by start length. #This turns curve length into a normalized value that is #useful for multiplying by UV values later to control stretch crvInfo = cmds.createNode('curveInfo', n=offsetCrv + "Info") cmds.connectAttr(offsetCrv + ".worldSpace[0]", crvInfo + ".ic") arcLength = cmds.getAttr(crvInfo + ".al") stretchAmountNode = cmds.createNode('multiplyDivide', n=offsetCrv + "Stretch") cmds.setAttr(stretchAmountNode + ".op" , 2) #divide cmds.setAttr(stretchAmountNode + ".input1X", arcLength) cmds.connectAttr( crvInfo + ".al",stretchAmountNode + ".input2X") #Stretch Blender blends start length with current length #and pipes it back into stretchAmoundNode's startLength, to "trick" it into #thinking there is no stretch.. #That way, when user turns on this "noStretch" attr, the startLength will #be made to equal current length, and stretchAmountNode will always be 1. #so the chain will not stretch. stretchBlender = cmds.createNode('blendColors', n =offsetCrv + "StretchBlender") cmds.setAttr(stretchBlender + ".c1r", arcLength) cmds.connectAttr(crvInfo + ".al", stretchBlender + ".c2r") cmds.connectAttr(stretchBlender + ".opr", stretchAmountNode + ".input1X") cmds.connectAttr(topNull + ".stretchAmount",stretchBlender + ".blender") #make skin joints and attach to surface skinJoints = [] skinJointParent = cmds.createNode('transform',n=crv + "_skinJoints",p=topNull) for i in range(numJoints): cmds.select(clear=True) jnt = cmds.joint(p=(0,0,0),n=crv + "_driverJoint%02d"%i) locator = cmds.spaceLocator(n=crv + "driverLoc%02d"%i)[0] cmds.setAttr(locator + ".localScale",stripWidth,stripWidth,stripWidth) cmds.parent(locator,hiddenStuff) percentage = float(i)/(numJoints-1.0) print "percentage:", percentage print i if i > 1 and i < numJoints-2: percentage = uMin + (percentage * (uMax-uMin)) print "\tinterp percent", percentage posNode,aimCnss,moPath,slider = self.attachObjToSurf(locator,surf,offsetCrv,stretchAmountNode,percentage) cmds.connectAttr(topNull + ".slideAmount", slider + ".i2") cmds.parentConstraint(locator,jnt,mo=False) if len(skinJoints): cmds.parent(jnt,skinJoints[-1]) else: cmds.parent(jnt,skinJointParent) skinJoints.append(jnt) cmds.setAttr(jnt + ".radius",stripWidth) #just cosmetic #add controls ctrls = [] stripJoints = [] stripJointParent = cmds.createNode('transform',n=crv + "_stripJoints",p=hiddenStuff) ctrlParent = cmds.createNode('transform',n=crv+"_Ctrls",p=topNull) for i in range(numCtrls): #The first control is larger, and has the stretch attr if i == 0: zero,ctrl = self.makeCubeCtrl(crv + "_Ctrl%02d"%i,size=ctrlWidth*1.8) cmds.addAttr(ctrl,ln="noStretch",dv=0.0,min=0,max=1,k=1,s=1) cmds.addAttr(ctrl,ln='slideAmount',dv=0.0,min=-1.0,max=1.0,k=1,s=1) cmds.connectAttr(ctrl + ".noStretch",topNull + ".stretchAmount") cmds.connectAttr(ctrl + ".slideAmount",topNull + ".slideAmount") else: zero,ctrl = self.makeCubeCtrl(crv + "_Ctrl%02d"%i,size=ctrlWidth) #Make the joint the control. These drive the nurbs strip. cmds.select(clear=True) jnt = cmds.joint(p=(0,0,0),n=ctrl + "StripJnt") cmds.parentConstraint(ctrl,jnt,mo=False) cmds.setAttr(jnt + ".radius", stripWidth * 1.3) #just cosmetic #briefly attach ctrls to strip to align them percentage = float(i)/(numCtrls-1.0) print "ctrl percentage:",percentage if i > 0 and i < numCtrls-1: percentage = uMin + (percentage * (uMax-uMin)) print '\tinterp percentage:', percentage cmds.delete(self.attachObjToSurf(zero,surf,offsetCrv,stretchAmountNode,percentage)) ctrls.append(ctrl) cmds.parent(jnt,stripJointParent) stripJoints.append(jnt) cmds.parent(zero,ctrlParent) #skin strip to controls #Can get some different behavior by chaning the strip's weights #or perhaps using dual quat. mode on the skinCluster skinObjs = stripJoints + [surf] cmds.skinCluster(skinObjs, bindMethod=0, #closest Point sm=0, #standard bind method ih=True, #ignore hierarchy ) #rebuild curve and skin to joints newCurve = cmds.duplicate(crv)[0] newCurve = cmds.rename(newCurve, crv + "_skinned") cmds.parent(newCurve, topNull) cmds.rebuildCurve(newCurve,ch=0,rpo=1,rt=0,end=1,kr=0,kcp=0,kep=1,kt=0,s=numJoints-2,d=3,tol=0.01) skinObjs = skinJoints + [newCurve] cmds.skinCluster(skinObjs, bindMethod = 0, sm = 0, ih=True, mi=1 ) if geo: wireDef,wireCrv = cmds.wire(geo,w=newCurve,n=crv + "_wire",dds=(0,10),en=1.0,ce=0,li=0) print wireDef cmds.parent(wireCrv,hiddenStuff) if cmds.objExists(wireCrv+"BaseWire"): cmds.parent(wireCrv+"BaseWire",hiddenStuff)
def postBuild(self): jointsNames = [] for i in range(len(self.Joints.outs)): exec('jointsNames.append( self.Joints.outs[{0}].str() )'.format(i)) self.utils_prepareJointForIk(jointsNames) # IK___________CREATE SOLVER mc.ikHandle(sj=self.Joints.outs[0].str(), ee=self.Joints.outs[-1].str(), sol='ikRPsolver', n=self.Name.handleIkSolver.str()) mc.parent(self.Name.handleIkSolver.str(), self.Name.rigGrp.str()) #mc.poleVectorConstraint( self.Pv.Name.ctrl.str() , self.Name.handleIkSolver.str() ) utilsMaya.buildConstraint( [self.CtrlB.outs[0].str(), self.Name.handleIkSolver.str()], ['parent', 'scale'], 'oneMaster', 1) utilsMaya.buildConstraint( [self.CtrlA.outs[0].str(), self.Joints.ins[0].str()], ['parent'], 'oneMaster', 1) utilsMaya.buildConstraint( [self.Pv.outs[0].str(), self.Name.handleIkSolver.str()], ['poleVector'], 'oneMaster', 0) # CREATE CURVE Curve = curveShape.curveShape() curveShapeName = Curve.utils_buildCurveShape(self.Name.curve.str(), 'None', self.pos, 3, 5) ctrlsName = [] for i in range(3, len(self.outs)): ctrlsName.append(self.outs[i].str()) Curve.utils_connectTransformsToCurve(ctrlsName, self.Name.curve.str()) mc.parent(self.Name.curve.str(), self.Name.rigGrp.str()) # CREATE thicknessCuve circleShape = mc.circle(nr=[1, 0, 0], n=self.Name.circle.str())[0] utilsMaya.buildConstraint( [self.Ctrl0.outs[0].str(), self.Name.circle.str()], ['parent'], 'oneMaster', 0) mc.connectAttr(self.Attr.ctrl.thickness.str(), self.Name.circle.str() + '.scaleX') mc.connectAttr(self.Attr.ctrl.thickness.str(), self.Name.circle.str() + '.scaleY') mc.connectAttr(self.Attr.ctrl.thickness.str(), self.Name.circle.str() + '.scaleZ') mc.parent(self.Name.circle.str(), self.Name.rigGrp.str()) #CREATE POLY TUBE extrudeOut = mc.extrude(circleShape, self.Name.curve.str(), ch=True, rn=True, po=1, et=2, ucp=1, fpt=0, upn=0, rotation=0, scale=1, rsp=1) extrudeMesh = extrudeOut[0] extrudeNode = extrudeOut[1] mc.rename(extrudeMesh, self.Name.outGeometry.str()) extrudeMesh = self.Name.outGeometry.str() #mc.parent( extrudeMesh , w = True ) mc.setAttr((extrudeNode + ".fixedPath"), 0) mc.setAttr((extrudeNode + ".useComponentPivot"), 0) mc.setAttr((extrudeNode + ".useProfileNormal"), 0) nurbsTessellateNode = mc.listConnections(extrudeNode + '.outputSurface', s=False, d=True)[0] mc.setAttr((nurbsTessellateNode + ".format"), 0) mc.setAttr((nurbsTessellateNode + ".polygonType"), 1) mc.connectAttr(self.Attr.ctrl.polyCount.str(), (nurbsTessellateNode + ".polygonCount")) #VISIBILITY mc.setAttr(self.Name.topNode.str() + ".skeletonVis", 1) mc.setAttr(self.Name.topNode.str() + ".skeletonRef", 2) mc.setAttr(self.Joints.Name.topNode.str() + ".v", 0) '''
def execute(self): sx = self.sx sy = self.sy sdv = self.sdv sdu = self.sdu tap = self.tap degs = self.degs subCurve = self.subCurve clean = self.clean do_uvs = self.do_uvs rbc = self.rbc cTol = self.cTol cSubd = self.cSubd if cmds.checkBox(self.aUACCB, q=True, v=True): useAltShape = True else: useAltShape = False multSel = cmds.ls(sl=True,fl=True, ap=True) if cmds.objectType(multSel[0]) == 'mesh': thisIsAMesh = True else: thisIsAMesh = False # Select curve type to extrude along - convert and store for x in multSel: print x if thisIsAMesh != True: cmds.select(x) else: cmds.select(multSel) objSel = cmds.ls(sl=True,fl=True, ap=True) if self.ko == 1: dupObj = cmds.duplicate(objSel) objSel = dupObj if len(objSel) > 1: print objSel if degs == 0: curveDg = cmds.promptDialog(t='Enter Degrees:', m='Enter Degrees - ie. 1 for linear, 3 for curved') objSel = cmds.polyToCurve(f=2, dg=int(cmds.promptDialog(q=True, tx=True))) else: objSel = cmds.polyToCurve(f=2, dg=int(degs), n='%s_curve' %objSel[0].split('.')[0]) else: objType = cmds.listRelatives(objSel[0], f=True) if cmds.objectType(objType[0]) != 'nurbsCurve' and cmds.objectType(objType[0]) != 'bezierCurve': cmds.error('Select the nurbs curve first, then the object to align') if cmds.objectType(objType[0]) == 'bezierCurve': mm.eval("bezierCurveToNurbs;") # Create a nurbs curve for the extrusion if useAltShape: nurbsCir = self.objToUse else: nurbsCir = cmds.circle(n='extrudeCircle', d=3, r=1, nr=(0,0,1), sw=360, ch=True, s=8) objCV = cmds.ls('%s.ep[*]' %objSel[0], fl=True) noOfCV = len(objCV) firstCV = 0 lastCV = noOfCV - 1 cvNumberToUse=firstCV # Rebuild the curve to help with uniformity if self.rev == 1: cmds.reverseCurve(objSel[0], ch=0, rpo=1) if rbc == 1: try: cmds.rebuildCurve(objSel[0], ch=0,rpo=1,rt=4,end=1,kr=0, kcp=0, kep=1, kt=0, s=cSubd, d=3, tol=cTol) cmds.rebuildCurve(objSel[0], ch=0,rpo=1,rt=0,end=1,kr=0, kcp=0, kep=1, kt=0, s=cSubd, d=3, tol=cTol) except: cmds.warning('Tolerance for rebuild likely to low, try a higher value or turn Rebuild Curve off') if do_uvs == 1: objShape = cmds.listRelatives(objSel[0], c=True, type='shape') mInfo = cmds.shadingNode('curveInfo', n='cMeasure', asUtility=True) cmds.connectAttr('%s.local' %objShape[0], '%s.inputCurve' %mInfo) curveLength = cmds.getAttr('%s.arcLength' %mInfo) cmds.delete(mInfo) self.uvRatio = float((((sx * sy)*2.0) * math.pi) / curveLength) print "uvRatio: " + str(self.uvRatio) # Create a tangent contraint to position nurbs circle to the first cv cvPos = cmds.xform('%s.ep[%d]' %(objSel[0],cvNumberToUse), query=True, ws=True, t=True) cmds.xform(nurbsCir[0], ws=True, t=(cvPos[0],cvPos[1],cvPos[2])) fastCon = cmds.tangentConstraint(objSel[0], nurbsCir[0], aim=(0,0,1)) cmds.delete(fastCon[0]) # Extrude along curve and set attributes pipeExt = cmds.extrude(nurbsCir[0], objSel[0], n='%s_pipe' %objSel[0], ch=True, rn=subCurve, po=1, et=2, ucp=1, fpt=1,upn=1, rotation=0, scale=1,rsp=1) pipeTes = cmds.listConnections(pipeExt[1], type='nurbsTessellate') if subCurve != 0: pipeSubCurve = cmds.listConnections(pipeExt[1], type='subCurve') cmds.setAttr('%s.format' %pipeTes[0],2) cmds.setAttr('%s.polygonType' %pipeTes[0],1) cmds.setAttr('%s.uType' %pipeTes[0],2) cmds.setAttr('%s.vType' %pipeTes[0],2) cmds.setAttr('%s.vNumber' %pipeTes[0],sdv) cmds.setAttr('%s.uNumber' %pipeTes[0],sdu) # Add attributes if clean == 0: cmds.addAttr(pipeExt[0], ln='________', k=True) cmds.setAttr('%s.________' %pipeExt[0], l=True) cmds.addAttr(pipeExt[0], ln='Ext_ScaleX', k=True, dv=sx) cmds.addAttr(pipeExt[0], ln='Ext_ScaleY', k=True, dv=sy) cmds.connectAttr('%s.Ext_ScaleX' %pipeExt[0], '%s.scaleX' %nurbsCir[0]) cmds.connectAttr('%s.Ext_ScaleY' %pipeExt[0], '%s.scaleY' %nurbsCir[0]) cmds.addAttr(pipeExt[0], ln='Ext_DivisionV', at='short', k=True, dv=sdv) cmds.connectAttr('%s.Ext_DivisionV' %pipeExt[0], '%s.vNumber' %pipeTes[0]) cmds.addAttr(pipeExt[0], ln='Ext_DivisionU', at='short', k=True, dv=sdu) cmds.connectAttr('%s.Ext_DivisionU' %pipeExt[0], '%s.uNumber' %pipeTes[0]) if subCurve != 0: cmds.addAttr(pipeExt[0], ln='Ext_Length', k=True, dv=1, max=1, min=0) cmds.connectAttr('%s.Ext_Length' %pipeExt[0], '%s.maxValue' %pipeSubCurve[1]) cmds.addAttr(pipeExt[0], ln='Ext_Taper', k=True, dv=tap, min=0) cmds.connectAttr('%s.Ext_Taper' %pipeExt[0], '%s.scale' %pipeExt[1]) cmds.addAttr(pipeExt[0], ln='Ext_Twist', k=True, dv=1) cmds.connectAttr('%s.Ext_Twist' %pipeExt[0], '%s.rotation' %pipeExt[1]) cmds.addAttr(pipeExt[0], ln='Ext_ComponentPivot', k=True, dv=1) cmds.connectAttr('%s.Ext_ComponentPivot' %pipeExt[0], '%s.useComponentPivot' %pipeExt[1]) curveGrpNode = cmds.createNode('transform', n='pipeCurves') cmds.parent(nurbsCir, curveGrpNode) cmds.parent(objSel, curveGrpNode) cmds.setAttr('%s.inheritsTransform' %curveGrpNode, 0) cmds.setAttr('%s.visibility' %curveGrpNode, 1) cmds.parent(curveGrpNode, pipeExt[0]) cmds.select(pipeExt[0]) if do_uvs == 1: cmds.polyLayoutUV(ps=0.2) cmds.polyEditUV(sv=1, su=self.uvRatio) cmds.polyEditUV(sv=0.95, su=0.95) cmds.select(pipeExt[0]) CentreUVs() if clean == 1: cmds.delete(ch=True) cmds.delete(curveGrpNode) cmds.select(pipeExt[0]) if thisIsAMesh == True: print 'hello' break
def extrude(*args): sel = cmds.ls(sl=True, exactType="transform") #keep = cmds.checkBoxGrp(widgets["keepCBG"], q=True, v1=True) if len(sel) < 3: cmds.warning( "You need to select the profile, then cap, then path curve in order!" ) return profileOrig = sel[0] cap = sel[1] curves = sel[2:] if not cmds.objExists("pastaRigSetupComponents_Grp"): cmds.group(empty=True, name="pastaRigSetupComponents_Grp") if not curveCheck(profileOrig): cmds.warning("Your first selection (profile) is not a curve!") return if not cmds.objExists("curveRebuild_originals_grp"): cmds.group(empty=True, name="curveRebuild_originals_grp") cmds.parent("curveRebuild_originals_grp", "pastaRigSetupComponents_Grp") cmds.parent(profileOrig, cap, "pastaRigSetupComponents_Grp") for curve in curves: if not curveCheck(curve): cmds.warning("{} is not a curve, skipping!".format(curve)) else: profile = cmds.duplicate(profileOrig, name="{}_profileCrv".format(curve))[0] newCap = cmds.duplicate(cap, returnRootsOnly=True, rebuildType=0, renameChildren=True, name="{}_capRig".format(curve))[0] # rigGrp = cmds.group(empty=True, name = "{}_rig_grp".format(curve)) curveResults = rebuildCurve(curve) newCrv = curveResults[0] rebuild = curveResults[1] cmds.parent(curve, "curveRebuild_originals_grp") capAxis = "y" capUp = "z" ctrl = rig.createControl(type="sphere", name="{}_CTRL".format(curve), color="blue") ctrlScale(ctrl) capGrp = cmds.group(empty=True, name="{}_cap_grp".format(curve)) deadGrp = cmds.group(empty=True, name="{}_noInherit_grp".format(curve)) cmds.parent(deadGrp, ctrl) #cmds.parent(ctrl, rigGrp) cmds.parent(newCap, capGrp) # add attrs to control cmds.addAttr(ctrl, ln="__xtraAttrs__", nn="__xtraAttrs__", at="bool", k=True) cmds.setAttr("{}.__xtraAttrs__".format(ctrl), l=True) cmds.addAttr(ctrl, ln="alongPath", at="float", min=0, max=100, k=True, dv=100.0) cmds.setAttr("{}.alongPath".format(ctrl), 100) cmds.addAttr(ctrl, ln="geoVis", at="long", min=0, max=1, k=True, dv=1) cmds.addAttr(ctrl, ln="pathCurveVis", at="long", min=0, max=1, k=True, dv=1) cmds.addAttr(ctrl, ln="__curveStuff__", nn="__curveStuff__", at="bool", k=True) cmds.setAttr("{}.__curveStuff__".format(ctrl), l=True) cmds.addAttr(ctrl, ln="density", at="float", min=0.02, max=8, k=True, dv=0.05) cmds.addAttr(ctrl, ln="radiusDivisions", at="float", k=True, min=1, max=3, dv=1.0) cmds.addAttr(ctrl, ln="reverseNormals", at="long", min=0, max=1, k=True) cmds.addAttr(ctrl, ln="capVisibility", at="long", min=0, max=1, k=True) cmds.setAttr("{}.capVisibility".format(ctrl), 1) cmds.addAttr(ctrl, ln="profileWidth", at="float", k=True, min=.001, max=3, dv=1.0) cmds.addAttr(ctrl, ln="capWidth", at="float", k=True, min=.01, max=2.0, dv=1.0) cmds.addAttr(ctrl, ln="capHeight", at="float", k=True, min=.01, max=2.0, dv=1.0) cmds.addAttr(ctrl, ln="rotateExtrusion", at="float", k=True, min=0, max=360) cmds.addAttr(ctrl, ln="rotateCap", at="float", k=True) cmds.addAttr(ctrl, ln="__textureAndRef__", nn="__textureAndRef__", at="bool", k=True) cmds.setAttr("{}.__textureAndRef__".format(ctrl), l=True) cmds.addAttr(ctrl, ln="textureRepeatMult", at="float", min=0.01, dv=1.0, k=True) cmds.addAttr(ctrl, ln="length", at="float", k=True) initLen = cmds.arclen(newCrv, ch=False) cmds.setAttr("{}.length".format(ctrl), initLen) cmds.setAttr("{}.length".format(ctrl), l=True) cmds.addAttr(ctrl, ln="geo", at="message") cmds.addAttr(ctrl, ln="fileTexture", at="message") cmds.addAttr(ctrl, ln="capRig", at="message") cmds.connectAttr("{}.message".format(newCap), "{}.capRig".format(ctrl)) # reference/driver attrs cmds.addAttr(ctrl, ln="prmHolder", at="float", k=True) cmds.addAttr(ctrl, ln="rptHolder", at="float", k=True) #cmds.setAttr("{}.radiusDivisions".format(ctrl), l=True) # connect mult to path mult = cmds.shadingNode("multiplyDivide", asUtility=True, name="{}_paraMult".format(curve)) cmds.connectAttr("{}.alongPath".format(ctrl), "{}.input1X".format(mult)) cmds.setAttr("{}.input2X".format(mult), 0.01) cmds.connectAttr("{}.profileWidth".format(ctrl), "{}.scaleX".format(profile)) cmds.connectAttr("{}.profileWidth".format(ctrl), "{}.scaleZ".format(profile)) # reverse for normals reverse = cmds.shadingNode("reverse", asUtility=True, name="{}_reverse".format(curve)) cmds.connectAttr("{}.reverseNormals".format(ctrl), "{}.inputX".format(reverse)) # cap, path and texture attrs and nodes cmds.connectAttr("{}.capVisibility".format(ctrl), "{}.v".format(capGrp)) repeatMult = cmds.shadingNode("multiplyDivide", asUtility=True, name="{}_RptMult".format(curve)) cmds.connectAttr("{}.outputX".format(mult), "{}.input1X".format(repeatMult)) cmds.connectAttr("{}.textureRepeatMult".format(ctrl), "{}.input2X".format(repeatMult)) cmds.connectAttr("{}.pathCurveVis".format(ctrl), "{}.visibility".format(newCrv)) #connect the rebuild density densityMult = cmds.shadingNode("multiplyDivide", asUtility=True, name="{}_DensityMult".format(curve)) cmds.connectAttr("{}.density".format(ctrl), "{}.input1X".format(densityMult)) cmds.connectAttr("{}.length".format(ctrl), "{}.input2X".format(densityMult)) cmds.connectAttr("{}.outputX".format(densityMult), "{}.spans".format(rebuild)) cmds.connectAttr("{}.outputX".format(repeatMult), "{}.rptHolder".format(ctrl)) cmds.connectAttr("{}.outputX".format(mult), "{}.prmHolder".format(ctrl)) cmds.setAttr("{}.prmHolder".format(ctrl), l=True) cmds.setAttr("{}.rptHolder".format(ctrl), l=True) cmds.connectAttr("{}.capWidth".format(ctrl), "{}.scaleX".format(capGrp)) cmds.connectAttr("{}.capWidth".format(ctrl), "{}.scaleZ".format(capGrp)) cmds.connectAttr("{}.capHeight".format(ctrl), "{}.scaleY".format(capGrp)) cmds.connectAttr("{}.rotateCap".format(ctrl), "{}.rotateY".format(newCap)) # position control at start of curve startPos = cmds.pointOnCurve(curve, parameter=0, position=True) cmds.xform(ctrl, ws=True, t=startPos) moPath = cmds.pathAnimation(capGrp, newCrv, fractionMode=True, follow=True, followAxis=capAxis, upAxis=capUp, worldUpType="scene", startTimeU=0.0, endTimeU=100.0) moPathAnimAttr = cmds.listConnections("{}.uValue".format(moPath), d=False, p=True)[0] start, end = getSliderRange() current = cmds.currentTime(q=True) cmds.currentTime(0) pPos = cmds.xform(capGrp, q=True, ws=True, rp=True) pRot = cmds.xform(capGrp, q=True, ws=True, ro=True) cmds.xform(profile, ws=True, t=pPos) cmds.xform(profile, ws=True, ro=pRot) cmds.currentTime(current) # extrude the curve extr = cmds.extrude(profile, newCrv, ch=True, range=True, polygon=True, extrudeType=2, useComponentPivot=True, fixedPath=True, useProfileNormal=True, reverseSurfaceIfPathReversed=True) extrGeo, extrNode = extr[0], extr[1] normal = cmds.polyNormal(extrGeo, normalMode=4, userNormalMode=0, ch=1)[0] cmds.connectAttr("{}.outputX".format(reverse), "{}.normalMode".format(normal)) cmds.connectAttr("{}.message".format(extrGeo), "{}.geo".format(ctrl)) cmds.connectAttr("{}.geoVis".format(ctrl), "{}.visibility".format(extrGeo)) cmds.connectAttr("{}.rotateExtrusion".format(ctrl), "{}.rotation".format(extrNode)) # get extrude connections connects = cmds.listConnections(extrNode) profNode, pathNode, tessNode = connects[0], connects[1], connects[ 2] # connect up stuff to extrusion cmds.connectAttr("{}.outputX".format(mult), "{}.maxValue".format(pathNode)) cmds.connectAttr("{}.radiusDivisions".format(ctrl), "{}.uNumber".format(tessNode)) cmds.parent(newCrv, ctrl) cmds.setAttr("{}.inheritsTransform".format(deadGrp), 0) cmds.parent(extrGeo, deadGrp) cmds.parent(profile, deadGrp) cmds.setAttr("{}.v".format(profile), 0) cmds.parent(capGrp, deadGrp) # motion path stuff cmds.delete(moPathAnimAttr.partition(".")[0]) cmds.connectAttr("{}.outputX".format(mult), "{}.uValue".format(moPath)) cmds.setAttr("{}.visibility".format(cap)) cmds.setAttr("{}.visibility".format(profileOrig))
shapes = cmds.listRelatives(c, s=True, path=True) curve0Pos = cmds.xform('%s.cv[0]' % shapes[0], q=True, t=True, ws=True) curve1Pos = cmds.xform('%s.cv[1]' % shapes[0], q=True, t=True, ws=True) newProfileCuve = cmds.duplicate(profileCurve) cmds.xform(newProfileCuve, t=curve0Pos, ws=True) aimPoint = cmds.spaceLocator(p=[0, 0, 0]) cmds.xform(aimPoint, t=curve1Pos, ws=True) tempConstraint = cmds.aimConstraint(aimPoint, newProfileCuve, aimVector=[0, 1, 0], upVector=[0, 1, 0]) cmds.delete(tempConstraint) cmds.delete(aimPoint) cmds.extrude(newProfileCuve, c, ch=True, rn=False, po=1, et=2, ucp=0, fpt=0, upn=1, rotation=0, scale=1, rsp=1)
def onPress(self): """ execute on press """ # modifier self.mod = cmds.getModifiers() # button self.btn = cmds.draggerContext(self.dragCtx, query=True, button=True) # timer self.timer = cmds.timerX() initPos = cmds.draggerContext(self.dragCtx, query=True, anchorPoint=True) # camera far clip currentView = omui.M3dView().active3dView() camDP = om.MDagPath() currentView.getCamera(camDP) camFn = om.MFnCamera(camDP) farclip = camFn.farClippingPlane() # screen to world conversion worldPos, worldDir = utils().viewToWorld(initPos[0],initPos[1]) if self.btn is not 2: closestHit = None closestObj = None for obj in self.targetObj: if cmds.objExists(obj): state, hit, fnMesh, facePtr, triPtr = utils().intersect(obj, worldPos, worldDir, farclip) if state is True: dif = [hit.x - worldPos[0],hit.y - worldPos[1],hit.z - worldPos[2]] distToCam = math.sqrt(math.pow(float(dif[0]),2) + math.pow(float(dif[1]),2) + math.pow(float(dif[2]),2)) if closestHit == None: closestHit = distToCam closestObj = [state, hit, fnMesh, facePtr, triPtr] elif distToCam < closestHit: closestHit = distToCam closestObj = [state, hit, fnMesh, facePtr, triPtr] else: self.targetObj.remove(obj) if closestObj is not None: state, hit, fnMesh, facePtr, triPtr = closestObj mHit = om.MPoint(hit) # get smooth normal normal = om.MVector() fnMesh.getClosestNormal(mHit, normal, om.MSpace.kWorld, None) # get smooth normal normal = om.MVector() fnMesh.getClosestNormal(mHit, normal, om.MSpace.kWorld, None) tangent = utils().crossProduct(normal,self.worldUp) upAxis = utils().crossProduct(normal,tangent) # define transformation matrix matrix = [tangent.x,tangent.y,tangent.z,0,upAxis.x,upAxis.y,upAxis.z,0,normal.x,normal.y,normal.z,0,hit.x,hit.y,hit.z,0] # create object if self.mod == 0: self.loc = cmds.curve(p = (hit.x,hit.y,hit.z)) # cmds.toggle(self.loc, localAxis=True) # store values self.prevHit = hit print self.prevHit self.screenPoint = initPos self.angle = 0 # draw Mesh if self.mesh is True and self.mod == 0: self.circle = cmds.circle(center = (hit.x,hit.y,hit.z),radius = self.bRad,d=3) self.extrude = cmds.extrude(self.circle[0],self.loc,po=1, ch=True,rn=False,et=2,ucp=0,fpt=0,upn=0,rotation=0,scale=1,rsp=1) self.nbTes = cmds.listConnections(self.extrude[1] + '.outputSurface')[0] cmds.setAttr(self.nbTes + '.polygonType',1) cmds.setAttr(self.nbTes + '.format',2) cmds.setAttr(self.nbTes + '.polygonCount',200) cmds.setAttr(self.nbTes + '.uType',3) cmds.setAttr(self.nbTes + '.uNumber',1) cmds.setAttr(self.nbTes + '.vType',3) cmds.setAttr(self.nbTes + '.vNumber',1) cmds.setAttr(self.extrude[1] + '.scale',self.taper) if self.autoAdd is True and self.extrude[0] not in self.targetObj: self.targetObj.append(self.extrude[0]) # refresh viewport cmds.refresh(cv=True)
def extrude(*args, **kwargs): res = cmds.extrude(*args, **kwargs) if not kwargs.get('query', kwargs.get('q', False)): res = _factories.maybeConvert(res, _general.PyNode) return res
def generateCity(self, *args): map_file = cmds.textField(self.widgets["osmFileTextField"], q = True, fi = True) winds_file = cmds.textField(self.widgets["wrfFileTextField"], q = True, fi = True) heights_file = cmds.textField(self.widgets["demFileTextField"], q = True, fi = True) jams_file = cmds.textField(self.widgets["jamsFileTextField"], q = True, fi = True) raw_wrf = cmds.checkBox(self.widgets["wrfCheckBox"], q=True, v=True) raw_dem = cmds.checkBox(self.widgets["demCheckBox"], q=True, v=True) if raw_wrf: if platform.system() == 'Windows': s = subprocess.check_output(["where", "python"], shell=True) else: s = subprocess.check_output(["which", "python"], shell=False) python_path = s.splitlines()[-1] script_dir = os.path.dirname(os.path.realpath(__file__)) winds_file = subprocess.check_output([python_path, script_dir + "\NetCDF_converter.py", map_file, winds_file], shell=False).rstrip() if raw_dem: if platform.system() == 'Windows': s = subprocess.check_output(["where", "python"], shell=True) else: s = subprocess.check_output(["which", "python"], shell=False) python_path = s.splitlines()[-1] script_dir = os.path.dirname(os.path.realpath(__file__)) heights_file = subprocess.check_output([python_path, script_dir + "\DEM_converter.py", map_file, heights_file], shell=False).rstrip() if cmds.objExists('city'): cmds.delete('city') def calc_emmiter_level(waypoints): if (jams_file == ""): return 0 jams_data = open(jams_file, 'r') sum_jams_level = 0 jams_points = 0 shift_lat = -0.00766 shift_lon = 0.006868 for waypoint in waypoints: for line in jams_data: tmp = line.split(' ') lon = float(tmp[0]) - shift_lon lat = float(tmp[1]) - shift_lat if lat < minlat or lat > maxlat or lon < minlon or lon > maxlon: continue data = float(tmp[2]) jams_point = convert_coordinates(lon, lat) dist = math.sqrt(math.pow(waypoint[0]-jams_point[0], 2)+math.pow(waypoint[2]-jams_point[2], 2)) if dist < (25.0/size_multiplier): sum_jams_level += data jams_points += 1 if jams_points >= (len(waypoints) * 0.5): return 1.0*sum_jams_level/jams_points else: return 0 jams_data.close() def convert_coordinates(lon, lat): centered_lat = (lat-minlat) - (maxlat-minlat)/2 centered_lon = (lon-minlon) - (maxlon-minlon)/2 normalized_lat = centered_lat * norm_lat normalized_lon = centered_lon * norm_lon return [normalized_lon, 0, -normalized_lat] #meters size_multiplier = float(cmds.textField(self.widgets["sizeMultTextField"], q = True, tx = True)) emit_multiplier = float(cmds.textField(self.widgets["emitMultTextField"], q = True, tx = True)) hasl = float(cmds.textField(self.widgets["haslTextField"], q = True, tx = True)) xmlData = xml.dom.minidom.parse(map_file) points_ids = [] points = [] heights = [] bounds = xmlData.getElementsByTagName("bounds")[0] minlat = float(bounds.getAttribute('minlat')) maxlat = float(bounds.getAttribute('maxlat')) minlon = float(bounds.getAttribute('minlon')) maxlon = float(bounds.getAttribute('maxlon')) dist_lon = self.coordinates_dist(minlon, minlat, maxlon, minlat) dist_lat = self.coordinates_dist(minlon, minlat, minlon, maxlat) norm_lat = (dist_lat/size_multiplier)/(maxlat-minlat) norm_lon = (dist_lon/size_multiplier)/(maxlon-minlon) #============================Get heights=================================== heights_data = open(heights_file, 'r') rows = 0 cols = 0 start_lon = 0 start_lat = 0 delta_lon = 0 delta_lat = 0 heights_matrix = [] for line in heights_data: tmp = line.strip().split(' ') if rows == 0: rows = float(tmp[0]) cols = float(tmp[1]) elif start_lon == 0: start_lon = float(tmp[0]) start_lat = float(tmp[1]) elif delta_lon == 0: delta_lon = float(tmp[0]) delta_lat = float(tmp[1]) else: row = [] for cell in tmp: row.append(int(cell)-hasl) heights_matrix.append(row) #========================================================================== maxprogress = 0 ways = xmlData.getElementsByTagName('way') for way in ways: tags = way.getElementsByTagName('tag') for tag in tags: tag_type = str(tag.getAttribute('k')) if (tag_type == 'highway'): subtype = str(tag.getAttribute('v')) if not(subtype == 'pedestrian') and not(subtype == 'steps') and not(subtype == 'footway') and not(subtype == 'cycleway'): maxprogress += 1 if (tag_type == 'building'): maxprogress += 1 progress = 0 cmds.progressWindow(title='Generating city', min = 0, max = maxprogress, progress = progress, status = 'Processing nodes', isInterruptable = False) #============================Handle nodes================================== nodes = xmlData.getElementsByTagName('node') for node in nodes: lat = float(node.getAttribute('lat')) lon = float(node.getAttribute('lon')) if lat < minlat or lat > maxlat or lon < minlon or lon > maxlon: continue point = convert_coordinates(lon, lat) points_ids.append(int(node.getAttribute('id'))) points.append(point) heights.append(heights_matrix[int(math.floor((lon-start_lon)/delta_lon))][int(math.floor((lat-start_lat)/delta_lat))]) #========================================================================== #=============================Handle ways================================== roads = 0 buildings = 0 emitter = 0 cmds.particle(n='nParticle') cmds.particle('nParticle', e=True, at='mass', order=0, fv=1e-5) cmds.setAttr('nParticleShape.lifespanMode', 2) cmds.setAttr('nParticleShape.lifespan', 6) cmds.setAttr('nParticleShape.lifespanRandom', 2) cmds.select('nParticleShape', r=True) cmds.addAttr(longName='betterIllumination', at='bool', defaultValue=False ) cmds.addAttr(longName='surfaceShading', at='float', defaultValue=0, minValue=0, maxValue=1) cmds.addAttr(longName='threshold', at='float', defaultValue=0, minValue=0, maxValue=10) cmds.addAttr(longName='radius', at='float', defaultValue=1, minValue=0, maxValue=20) cmds.addAttr(longName='flatShaded', at='bool', defaultValue=False) cmds.setAttr('nParticleShape.particleRenderType', 8) cmds.setAttr('nParticleShape.radius', 0.06) cmds.setAttr('particleCloud1.transparency', 0.53, 0.53, 0.53, type='double3') cmds.setAttr('particleCloud1.color', 1.0, 0.0, 0.483, type='double3') cmds.setAttr('particleCloud1.incandescence', 1.0, 0.0, 0.850, type='double3') cmds.setAttr('particleCloud1.glowIntensity', 0.111) ways = xmlData.getElementsByTagName('way') for way in ways: waypoints = [] heights_sum = 0 nodes = way.getElementsByTagName('nd') tags = way.getElementsByTagName('tag') for node in nodes: ref = int(node.getAttribute('ref')) try: index = points_ids.index(ref) except ValueError: index = -1 if index != -1: waypoints.append(points[index]) heights_sum += heights[index] for tag in tags: tag_type = str(tag.getAttribute('k')) if tag_type == 'highway': subtype = str(tag.getAttribute('v')) if not(subtype == 'pedestrian') and not(subtype == 'steps') and not(subtype == 'footway') and not(subtype == 'cycleway'): roads += 1 progress += 1 cmds.progressWindow(edit=True, progress = progress, status='Generating road: ' + str(roads)) lanes = 2 for tag in tags: tag_type = str(tag.getAttribute('k')) if tag_type == 'lanes': lanes = float(str(tag.getAttribute('v'))) if len(waypoints) >= 2: cmds.curve(n='pathcurve_' + str(roads), p=waypoints, d=1) sx = waypoints[0][0] sz = waypoints[0][2] dx = waypoints[0][2]-waypoints[1][2] dz = waypoints[1][0]-waypoints[0][0] ln = math.sqrt(math.pow(2*dx, 2) + math.pow(2*dz, 2)) dx /= (ln*size_multiplier)/(3*lanes) dz /= (ln*size_multiplier)/(3*lanes) ln = 0 for i in range(0, len(waypoints)-2): ln += math.trunc(math.sqrt(math.pow(waypoints[i+1][0]-waypoints[i][0], 2) + math.pow(waypoints[i+1][2]-waypoints[i][2], 2))) + 1 cmds.curve(n='extrudecurve_' + str(roads), p=[(sx-dx, 0, sz-dz), (sx+dx, 0, sz+dz)], d=1) cmds.rebuildCurve('pathcurve_' + str(roads), rt=0, s=200) cmds.nurbsToPolygonsPref(f=2, pt=1, ut=1, un=2, vt=1, vn=ln * 5 + 30) cmds.extrude('extrudecurve_' + str(roads), 'pathcurve_' + str(roads), n='road_' + str(roads), et=2, po=1) cmds.delete('extrudecurve_' + str(roads),) emitter_level = calc_emmiter_level(waypoints) if emitter_level > 0: emitter += 1 cmds.select('pathcurve_' + str(roads), r=True) cmds.move(0, 0.03, 0) cmds.emitter(n='emitter_' + str(emitter), type='omni', r=emit_multiplier*emitter_level, spd=0.1, srn=0, sp=0) cmds.connectDynamic('nParticle', em='emitter_' + str(emitter)) cmds.select('road_' + str(roads), r=True) cmds.move(0, 0.004, 0) elif tag_type == 'building': temp = str(tag.getAttribute('v')) if temp == 'yes': buildings += 1 progress += 1 cmds.progressWindow(edit=True, progress = progress, status='Generating building: ' + str(buildings)) if len(waypoints) >= 3: cmds.polyCreateFacet(n='building_' + str(buildings), p=waypoints) cmds.select('building_' + str(buildings), r=True) normal = cmds.polyInfo(fn=True)[0].partition('0: ')[2].split(' ')[1] if float(normal) < 0: cmds.polyMirrorFace(direction=2, p=(0, 0, 0), mergeMode=0, worldSpace=1) cmds.polyDelFacet('building_' + str(buildings) + '.f[0]') avg_height = heights_sum / len(waypoints) cmds.polyExtrudeFacet('building_' + str(buildings) + '.f[0]', ltz=(1.0 * avg_height/size_multiplier)) cmds.select('building_' + str(buildings), r=True) cmds.collision('building_' + str(buildings), 'nParticle') #========================================================================== #============================Handle winds================================== winds_data = open(winds_file, 'r') winds = 0 cmds.progressWindow(edit=True, progress = progress, status='Setting winds') for line in winds_data: winds += 1 tmp = line.split(' ') lon = float(tmp[0]) lat = float(tmp[1]) x = float(tmp[2]) y = float(tmp[3]) z = float(tmp[4]) magn = math.sqrt(math.pow(x, 2) + math.pow(y, 2) + math.pow(z, 2)) max_dist = self.coordinates_dist(0, 0, 0.006364, 0.006364)/size_multiplier volume_size = self.coordinates_dist(0, 0, 0.0045, 0.0045)/size_multiplier position = convert_coordinates(lon, lat) cmds.air(n='wind_' + str(winds), pos=position, wns=True, dx=x, dy=y, dz=z, m=magn, s=1, mxd=max_dist) cmds.setAttr('wind_' + str(winds) + '.volumeShape', 1) cmds.setAttr('wind_' + str(winds) + '.volumeOffsetY', 1) cmds.scale(volume_size, volume_size/2, volume_size, 'wind_' + str(winds)) cmds.connectDynamic('nParticle', f='wind_' + str(winds)) cmds.select(cl=True) #========================================================================== cmds.gravity(n='gravity', m=9.8*1e-5) cmds.connectDynamic('nParticle', f='gravity') cmds.polyPlane(n='ground', sx=(maxlon-minlon), sy=(maxlat-minlat), w=(maxlon-minlon)*norm_lon, h=(maxlat-minlat)*norm_lat) cmds.collision('ground', 'nParticle') cmds.select('building_*', r=True) cmds.select('road_*', tgl=True) cmds.select('ground', tgl=True) cmds.select('nParticle', tgl=True) cmds.editRenderLayerGlobals(currentRenderLayer='AOLayer') cmds.editRenderLayerMembers('AOLayer') cmds.select('road_*', r=True) cmds.group(n='roads') cmds.select('building_*', r=True) cmds.group(n='buildings') cmds.select('pathcurve_*', r=True) cmds.group(n='emitters') cmds.select('roads', r=True) cmds.select('buildings', tgl=True) cmds.select('emitters', tgl=True) cmds.select('nParticle', tgl=True) cmds.select('gravity', tgl=True) cmds.select('ground', tgl=True) cmds.select('wind_1', tgl=True) cmds.group(n='city') xmlData.unlink() winds_data.close() heights_data.close() if raw_wrf: os.remove(winds_file) if raw_dem: os.remove(heights_file) cmds.progressWindow(endProgress = True)