def createFromEditPointList(pointList,degree=3,form=1,prefix='curve'): ''' Build a nurbs curve from a list of edit point positions @param pointList: List of edit point positions @type pointList: list @param degree: Degree of the curve to create @type degree: int @param form: Form of the curve to create. 1 = Open, 2 = Closed, 3 = Periodic @type form: int @param prefix: Name prefix for newly created nodes @type prefix: str @return: The curve created based on input argument values @returnType: str ''' # Creat degree 1 curve from point list curve = createFromPointList(pointList,1,prefix) # Fit degree 3 curve fitCurve = mc.fitBspline(curve,ch=0,tol=0.01) # Delete original curve mc.delete(curve) # Rename fit curve curve = mc.rename(fitCurve[0],curve) # Return curve return curve
def crvTendon(curve,geo,precision=4,prefix='tendon'): ''' ''' # rebuildCurve degree 1 baseCurve = mc.rebuildCurve(curve,ch=0,s=1,d=1,rpo=1,rt=0,end=1,kr=0,kcp=0,kep=1,kt=1) # create cv locators baseLocs = glTools.utils.curve.locatorCurve(baseCurve,prefix=prefix+'_baseCrv') # generate geo constraint curve geoCurve = mc.rebuildCurve(baseCurve,ch=1,s=precsion,d=1,rpo=0,rt=0,end=1,kr=0,kcp=0,kep=1,kt=1) geoCurveLocs = glTools.utils.curve.locatorCurve(geoCurve,prefix=prefix+'_geoCrv') # generate reference curve refCurve = mc.rebuildCurve(baseCurve,ch=1,s=precsion,d=1,rpo=0,rt=0,end=1,kr=0,kcp=0,kep=1,kt=1) refCurveInfo = mc.createNode('curveInfo',n=prefix+'_ref_curveInfo') mc.connectAttr(refCurve+'.worldSpace[0]',refCurveInfo+'.inputCurve',f=True) refCurveLocs = [] for i in range(precsion+1): refNull = mc.group(em=True,n=prefix+'_ref'+str(i)+'_null') mc.connectAttr(refCurveInfo+'.controlPoints['+str(i)+']',refNull+'.t') refCurveLocs.append(refNull) # Locator Constraints for i in range(precsion+1): mc.pointConstraint(refCurveLocs[i],geoCurveLocs[i]) mc.geometryConstraint(geo,geoCurveLocs[i]) # fitBspline bSpline = mc.fitBspline(geoCurve,ch=1)
def buildwithMesh(*args): if cmds.window("dynamo_locators", exists=True): cmds.deleteUI("dynamo_locators") if cmds.window("dupSpecialX", exists=True): cmds.deleteUI("dupSpecialX") if cmds.window("dupSpecialY", exists=True): cmds.deleteUI("dupSpecialY") if cmds.window("dupSpecialZ", exists=True): cmds.deleteUI("dupSpecialZ") #/joints herstellen/ locatorListe = cmds.ls(selection=True) listLaenge = len(locatorListe) if listLaenge > 4: firstLocator = locatorListe[0] queryFirstLocatorPos = cmds.xform(firstLocator, translation=True, q=True) createController = cmds.circle(nr=(0, 1, 0), c=(queryFirstLocatorPos), r=10, d=1, s=6, n="root_Controller") centerPivotController = cmds.xform(createController, cp=True) cmds.makeIdentity(createController, apply=True, t=1, r=1, s=1, n=0) jointList = [] for i in locatorListe: queryLocPos = cmds.xform(i, translation=True, q=True) cmds.select(clear=True) createJoint = cmds.joint(p=(queryLocPos)) jointList.append(createJoint) cmds.select(clear=True) print jointList #parenting root_Joint to root_Controller mainController = createController #listJoint=cmds.ls(type="joint") firstJoint = jointList[0] pointConstraint = cmds.pointConstraint(mainController, firstJoint, mo=True) orientConstraint = cmds.orientConstraint(mainController, firstJoint, mo=True) cmds.select(clear=True) #/joints parenting/ #jointListe = cmds.ls(type = "joint",v=True) for i, inhalt in enumerate(jointList): # Break Loop if i == 0: continue vorheriges = jointList[i - 1] aktuelles = inhalt cmds.parent(aktuelles, vorheriges) cmds.select(clear=True) #/Query Start-End-Number/ queryStartNumber = cmds.textField('startLoc', text=True, q=True) print queryStartNumber queryEndNumber = cmds.textField('endLoc', text=True, q=True) print queryEndNumber start = int(queryStartNumber) end = int(queryEndNumber) #/create Curve/ #jointListe = cmds.ls(type = "joint",v=True) endJoint = len(jointList) jointListwitoutfirst = jointList[start:end] jnListlaenge = len(jointListwitoutfirst) if jnListlaenge > 0: curve_degree = 3 jointPos = [] for i in jointListwitoutfirst: queryJnPos = cmds.xform(i, ws=True, translation=True, query=True) jointPos.append(queryJnPos) #print jointPos cvCurve = cmds.curve(d=curve_degree, p=jointPos, ws=True, n="Curve1") epCurve = cmds.fitBspline(ch=1, tol=0.0, n="Original_Curve") cmds.rename("Original_Curve", "DynamoOrgCurve") cmds.delete(cvCurve) #/make dynamic curve/ mel.eval('makeCurvesDynamicHairs %d %d %d' % (True, False, True)) #/iksplineHAndle/ sel = cmds.ls(type="joint", v=True) startjoint = jointList[start] endeffector = jointList[end] #print startjoint, endeffector ikSplineHandle = cmds.ikHandle(n="dynamoIkHandle", sj=startjoint, ee=endeffector, solver='ikSplineSolver', p=2, c="curve1", tws="linear", pcv=True, ccv=False, snc=False) renameiKHandleCurve = cmds.rename("curve1", "NewDynamoCurve") NewDyCurve = renameiKHandleCurve #/change follicle point lock/ querypointLockOptionMenu = cmds.optionMenu("pointLockOptionMenu", q=True, value=True)[0] print querypointLockOptionMenu pointLock = int(querypointLockOptionMenu) follicleList = cmds.ls("follicle1") for o in follicleList: setPointLockBase = cmds.setAttr(o + ".pointLock", pointLock) cmds.rename("follicle1", "DynamoFollicle") #/hide/ #cmds.hide( cmds.ls( type="joint" ) ) #/skin/ addBodyMesh = cmds.textField('SMesh', text=True, query=True) cmds.skinCluster(addBodyMesh, jointList[start:end], tsb=True, nw=3, mi=7, dr=10.0, ih=True) #/renaming Joints/ jointListe = cmds.ls(type="joint", v=True) rootJoint = jointList[0] endJoint = jointList[0 - 1] #print endJoint endNewName = "end_Joint" rootNewName = "root_Joint" cmds.rename(rootJoint, rootNewName) cmds.rename(endJoint, endNewName) count = 1 #/cleaning and parenting/ cmds.parent("hairSystem" + count + "Follicles", "root_Joint") count += 1 cmds.hide("DynamoOrgCurve") cmds.select(clear=True) Data = cmds.group(NewDyCurve, ikSplineHandle, "hairSystem1", "hairSystem1OutputCurves", w=True, n="Data") cmds.parent("effector1", "end_Joint") cmds.select(clear=True) hideIkHandle = cmds.hide("dynamoIkHandle") cmds.select(clear=True) cmds.hide(cmds.ls(type="locator")) cmds.select(clear=True) else: cmds.warning("Select Locators")
def traceArc(space='camera'): ''' The main function for creating the arc. ''' if space != 'world' and space != 'camera': OpenMaya.MGlobal.displayWarning('Improper space argument.') return global ML_TRACE_ARC_PREVIOUS_SELECTION global ML_TRACE_ARC_PREVIOUS_SPACE #save for reset: origTime = mc.currentTime(query=True) #frame range frameRange = utl.frameRange() start = frameRange[0] end = frameRange[1] #get neccesary nodes objs = mc.ls(sl=True, type='transform') if not objs: OpenMaya.MGlobal.displayWarning('Select objects to trace') return ML_TRACE_ARC_PREVIOUS_SELECTION = objs ML_TRACE_ARC_PREVIOUS_SPACE = space cam = None nearClipPlane = None shortCam = '' if space=='camera': cam = utl.getCurrentCamera() #the arc will be placed just past the clip plane distance, but no closer than 1 unit. nearClipPlane = max(mc.getAttr(cam+'.nearClipPlane'),1) shortCam = mc.ls(cam, shortNames=True)[0] topGroup = 'ml_arcGroup' worldGrp = 'ml_arcWorldGrp' localGrp = 'ml_localGrp_'+shortCam #create nodes if not mc.objExists(topGroup): topGroup = mc.group(empty=True, name=topGroup) parentGrp = topGroup if space=='world' and not mc.objExists(worldGrp): worldGrp = mc.group(empty=True, name=worldGrp) mc.setAttr(worldGrp+'.overrideEnabled',1) mc.setAttr(worldGrp+'.overrideDisplayType',2) mc.parent(worldGrp, topGroup) parentGrp = mc.ls(worldGrp)[0] if space == 'camera': camConnections = mc.listConnections(cam+'.message', plugs=True, source=False, destination=True) if camConnections: for cc in camConnections: if '.ml_parentCam' in cc: localGrp = mc.ls(cc, o=True)[0] if not mc.objExists(localGrp): localGrp = mc.group(empty=True, name=localGrp) mc.parentConstraint(cam, localGrp) mc.setAttr(localGrp+'.overrideEnabled',1) mc.setAttr(localGrp+'.overrideDisplayType',2) mc.parent(localGrp, topGroup) mc.addAttr(localGrp, at='message', longName='ml_parentCam') mc.connectAttr(cam+'.message', localGrp+'.ml_parentCam') parentGrp = mc.ls(localGrp)[0] #group per object: group = list() points = list() for i,obj in enumerate(objs): sn = mc.ls(obj,shortNames=True)[0] name = sn.replace(':','_') points.append(list()) groupName = 'ml_%s_arcGrp' % name if mc.objExists(groupName): mc.delete(groupName) group.append(mc.group(empty=True, name=groupName)) group[i] = mc.parent(group[i],parentGrp)[0] mc.setAttr(group[i]+'.translate', 0,0,0) mc.setAttr(group[i]+'.rotate', 0,0,0) with utl.UndoChunk(): with utl.IsolateViews(): #helper locator loc = mc.spaceLocator()[0] mc.parent(loc,parentGrp) #frame loop: time = range(int(start),int(end+1)) for t in time: mc.currentTime(t, edit=True) #object loop for i,obj in enumerate(objs): objPnt = mc.xform(obj, query=True, worldSpace=True, rotatePivot=True) if space=='camera': camPnt = mc.xform(cam, query=True, worldSpace=True, rotatePivot=True) objVec = euclid.Vector3(objPnt[0],objPnt[1],objPnt[2]) camVec = euclid.Vector3(camPnt[0],camPnt[1],camPnt[2]) vec = objVec-camVec vec.normalize() #multiply here to offset from camera vec=vec*nearClipPlane*1.2 vec+=camVec mc.xform(loc, worldSpace=True, translation=vec[:]) trans = mc.getAttr(loc+'.translate') points[i].append(trans[0]) elif space=='world': points[i].append(objPnt) mc.delete(loc) #create the curves and do paint effects mc.ResetTemplateBrush() brush = mc.getDefaultBrush() mc.setAttr(brush+'.screenspaceWidth',1) mc.setAttr(brush+'.distanceScaling',0) mc.setAttr(brush+'.brushWidth',0.005) for i,obj in enumerate(objs): #setup brush for path mc.setAttr(brush+'.screenspaceWidth',1) mc.setAttr(brush+'.distanceScaling',0) mc.setAttr(brush+'.brushWidth',0.003) #color for c in ('R','G','B'): color = random.uniform(0.3,0.7) mc.setAttr(brush+'.color1'+c,color) baseCurve = mc.curve(d=3,p=points[i]) #fitBspline makes a curve that goes THROUGH the points, a more accurate path curve = mc.fitBspline(baseCurve, constructionHistory=False, tolerance=0.001) mc.delete(baseCurve) #paint fx mc.AttachBrushToCurves(curve) stroke = mc.ls(sl=True)[0] stroke = mc.parent(stroke,group[i])[0] mc.setAttr(stroke+'.overrideEnabled',1) mc.setAttr(stroke+'.overrideDisplayType',2) mc.setAttr(stroke+'.displayPercent',92) mc.setAttr(stroke+'.sampleDensity',0.5) mc.setAttr(stroke+'.inheritsTransform',0) mc.setAttr(stroke+'.translate',0,0,0) mc.setAttr(stroke+'.rotate',0,0,0) curve = mc.parent(curve,group[i])[0] mc.setAttr(curve+'.translate',0,0,0) mc.setAttr(curve+'.rotate',0,0,0) mc.hide(curve) #setup brush for tics if space=='camera': mc.setAttr(brush+'.brushWidth',0.008) if space=='world': mc.setAttr(brush+'.brushWidth',0.005) mc.setAttr(brush+'.color1G',0) mc.setAttr(brush+'.color1B',0) for t in range(len(points[i])): frameCurve = None if space=='camera': vec = euclid.Vector3(points[i][t][0],points[i][t][1],points[i][t][2]) vec*=0.98 frameCurve = mc.curve(d=1,p=[points[i][t],vec[:]]) elif space=='world': frameCurve = mc.circle(constructionHistory=False, radius=0.0001, sections=4)[0] mc.setAttr(frameCurve+'.translate', points[i][t][0], points[i][t][1] ,points[i][t][2]) constraint = mc.tangentConstraint(curve, frameCurve, aimVector=(0,0,1), worldUpType='scene') #mc.delete(constraint) #check for keyframe colorAttribute='color1G' if mc.keyframe(obj, time=((t+start-0.5),(t+start+0.5)), query=True): mc.setAttr(brush+'.color1R',1) else: mc.setAttr(brush+'.color1R',0) mc.AttachBrushToCurves(curve) stroke = mc.ls(sl=True)[0] thisBrush = mc.listConnections(stroke+'.brush', destination=False)[0] #setup keyframes for frame highlighting mc.setKeyframe(thisBrush, attribute='color1G', value=0, time=(start+t-1, start+t+1)) mc.setKeyframe(thisBrush, attribute='color1G', value=1, time=(start+t,)) stroke = mc.parent(stroke,group[i])[0] mc.hide(frameCurve) mc.setAttr(stroke+'.displayPercent',92) mc.setAttr(stroke+'.sampleDensity',0.5) frameCurve = mc.parent(frameCurve,group[i])[0] if space=='camera': mc.setAttr(stroke+'.inheritsTransform',0) mc.setAttr(stroke+'.pressureScale[1].pressureScale_Position', 1) mc.setAttr(stroke+'.pressureScale[1].pressureScale_FloatValue', 0) mc.setAttr(stroke+'.translate',0,0,0) mc.setAttr(stroke+'.rotate',0,0,0) mc.setAttr(frameCurve+'.translate',0,0,0) mc.setAttr(frameCurve+'.rotate',0,0,0) mc.currentTime(origTime, edit=True) panel = mc.getPanel(withFocus=True) mc.modelEditor(panel, edit=True, strokes=True) mc.select(objs,replace=True)
def fitBspline(*args, **kwargs): res = cmds.fitBspline(*args, **kwargs) if not kwargs.get('query', kwargs.get('q', False)): res = _factories.maybeConvert(res, _general.PyNode) return res
def traceArc(space='camera'): ''' The main function for creating the arc. ''' if space not in ('world','camera'): OpenMaya.MGlobal.displayWarning('Improper space argument.') return global ML_TRACE_ARC_PREVIOUS_SELECTION global ML_TRACE_ARC_PREVIOUS_SPACE globalScale = 1 if mc.optionVar(exists='ml_arcTracer_brushGlobalScale'): globalScale = mc.optionVar(query='ml_arcTracer_brushGlobalScale') #save for reset: origTime = mc.currentTime(query=True) #frame range frameRange = utl.frameRange() start = frameRange[0] end = frameRange[1] #get neccesary nodes objs = mc.ls(sl=True, type='transform') if not objs: OpenMaya.MGlobal.displayWarning('Select objects to trace') return ML_TRACE_ARC_PREVIOUS_SELECTION = objs ML_TRACE_ARC_PREVIOUS_SPACE = space cam = None nearClipPlane = None shortCam = '' if space=='camera': cam = utl.getCurrentCamera() #the arc will be placed just past the clip plane distance, but no closer than 1 unit. nearClipPlane = max(mc.getAttr(cam+'.nearClipPlane'),1) shortCam = mc.ls(cam, shortNames=True)[0] topGroup = 'ml_arcGroup' worldGrp = 'ml_arcWorldGrp' localGrp = 'ml_localGrp_'+shortCam #create nodes if not mc.objExists(topGroup): topGroup = mc.group(empty=True, name=topGroup) parentGrp = topGroup if space=='world' and not mc.objExists(worldGrp): worldGrp = mc.group(empty=True, name=worldGrp) mc.setAttr(worldGrp+'.overrideEnabled',1) mc.setAttr(worldGrp+'.overrideDisplayType',2) mc.parent(worldGrp, topGroup) parentGrp = mc.ls(worldGrp)[0] if space == 'camera': camConnections = mc.listConnections(cam+'.message', plugs=True, source=False, destination=True) if camConnections: for cc in camConnections: if '.ml_parentCam' in cc: localGrp = mc.ls(cc, o=True)[0] if not mc.objExists(localGrp): localGrp = mc.group(empty=True, name=localGrp) mc.parentConstraint(cam, localGrp) mc.setAttr(localGrp+'.overrideEnabled',1) mc.setAttr(localGrp+'.overrideDisplayType',2) mc.parent(localGrp, topGroup) mc.addAttr(localGrp, at='message', longName='ml_parentCam') mc.connectAttr(cam+'.message', localGrp+'.ml_parentCam') parentGrp = mc.ls(localGrp)[0] #group per object: group = [] for i,obj in enumerate(objs): sn = mc.ls(obj,shortNames=True)[0] name = sn.replace(':','_') groupName = 'ml_{}_arcGrp'.format(name) if mc.objExists(groupName): mc.delete(groupName) group.append(mc.group(empty=True, name=groupName)) group[i] = mc.parent(group[i],parentGrp)[0] mc.setAttr(group[i]+'.translate', 0,0,0) mc.setAttr(group[i]+'.rotate', 0,0,0) with utl.UndoChunk(): #determine the method to run. Test fast against accurate. #If fast is the same, continue with fast method. #Otherwise revert to accurate method. mc.currentTime(start) fastPoints = arcDataFast([objs[0]], parentGrp, start+1, start+1, space, nearClipPlane, cam) accuratePoints = arcDataAccurate([objs[0]], parentGrp, start+1, start+1, space, nearClipPlane, cam) points = None #if they're equivalent, continue with fast: if [int(x*1000000) for x in fastPoints[0][0]] == [int(x*1000000) for x in accuratePoints[0][0]]: points = arcDataFast([objs[0]], parentGrp, start, end, space, nearClipPlane, cam) else: points = arcDataAccurate([objs[0]], parentGrp, start, end, space, nearClipPlane, cam) #create the curves and do paint effects mc.ResetTemplateBrush() brush = mc.getDefaultBrush() mc.setAttr(brush+'.screenspaceWidth',1) mc.setAttr(brush+'.distanceScaling',0) mc.setAttr(brush+'.brushWidth',0.005) for i,obj in enumerate(objs): #setup brush for path globalScale mc.setAttr(brush+'.globalScale', globalScale) mc.setAttr(brush+'.screenspaceWidth',1) mc.setAttr(brush+'.distanceScaling',0) mc.setAttr(brush+'.brushWidth',0.003) #color for c in ('R','G','B'): color = random.uniform(0.3,0.7) mc.setAttr(brush+'.color1'+c,color) baseCurve = mc.curve(d=3,p=points[i]) #fitBspline makes a curve that goes THROUGH the points, a more accurate path curve = mc.fitBspline(baseCurve, constructionHistory=False, tolerance=0.001, name='ml_arcTracer_curve_#') mc.delete(baseCurve) #paint fx mc.AttachBrushToCurves(curve) stroke = mc.ls(sl=True)[0] mc.rename(mc.listConnections(stroke+'.brush', destination=False)[0], 'ml_arcTracer_brush_#') stroke = mc.parent(stroke,group[i])[0] mc.setAttr(stroke+'.overrideEnabled',1) mc.setAttr(stroke+'.overrideDisplayType',2) mc.setAttr(stroke+'.displayPercent',92) mc.setAttr(stroke+'.sampleDensity',0.5) mc.setAttr(stroke+'.inheritsTransform',0) mc.setAttr(stroke+'.translate',0,0,0) mc.setAttr(stroke+'.rotate',0,0,0) curve = mc.parent(curve,group[i])[0] mc.setAttr(curve+'.translate',0,0,0) mc.setAttr(curve+'.rotate',0,0,0) mc.hide(curve) #setup brush for tics if space=='camera': mc.setAttr(brush+'.brushWidth',0.008) if space=='world': mc.setAttr(brush+'.brushWidth',0.005) mc.setAttr(brush+'.color1G',0) mc.setAttr(brush+'.color1B',0) for t in range(len(points[i])): frameCurve = None if space=='camera': vec = utl.Vector(points[i][t][0],points[i][t][1],points[i][t][2]) vec*=0.98 frameCurve = mc.curve(d=1,p=[points[i][t],vec[:]]) elif space=='world': frameCurve = mc.circle(constructionHistory=False, radius=0.0001, sections=4)[0] mc.setAttr(frameCurve+'.translate', points[i][t][0], points[i][t][1], points[i][t][2]) constraint = mc.tangentConstraint(curve, frameCurve, aimVector=(0,0,1), worldUpType='scene') #mc.delete(constraint) #check for keyframe colorAttribute='color1G' if mc.keyframe(obj, time=((t+start-0.5),(t+start+0.5)), query=True): mc.setAttr(brush+'.color1R',1) else: mc.setAttr(brush+'.color1R',0) mc.AttachBrushToCurves(curve) stroke = mc.ls(sl=True)[0] thisBrush = mc.listConnections(stroke+'.brush', destination=False)[0] thisBrush = mc.rename(thisBrush, 'ml_arcTracer_brush_#') #setup keyframes for frame highlighting mc.setKeyframe(thisBrush, attribute='color1G', value=0, time=(start+t-1, start+t+1)) mc.setKeyframe(thisBrush, attribute='color1G', value=1, time=(start+t,)) stroke = mc.parent(stroke,group[i])[0] mc.hide(frameCurve) mc.setAttr(stroke+'.displayPercent',92) mc.setAttr(stroke+'.sampleDensity',0.5) frameCurve = mc.parent(frameCurve,group[i])[0] if space=='camera': mc.setAttr(stroke+'.inheritsTransform',0) mc.setAttr(stroke+'.pressureScale[1].pressureScale_Position', 1) mc.setAttr(stroke+'.pressureScale[1].pressureScale_FloatValue', 0) mc.setAttr(stroke+'.translate',0,0,0) mc.setAttr(stroke+'.rotate',0,0,0) mc.setAttr(frameCurve+'.translate',0,0,0) mc.setAttr(frameCurve+'.rotate',0,0,0) mc.currentTime(origTime, edit=True) panel = mc.getPanel(withFocus=True) try: mc.modelEditor(panel, edit=True, strokes=True) except: pass mc.select(objs,replace=True) mc.refresh()
def crvTendon(curve, geo, precision=4, prefix='tendon'): """ """ # rebuildCurve degree 1 baseCurve = cmds.rebuildCurve(curve, ch=0, s=1, d=1, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt=1) # create cv locators baseLocs = glTools.utils.curve.locatorCurve(baseCurve, prefix=prefix + '_baseCrv') # generate geo constraint curve geoCurve = cmds.rebuildCurve(baseCurve, ch=1, s=precsion, d=1, rpo=0, rt=0, end=1, kr=0, kcp=0, kep=1, kt=1) geoCurveLocs = glTools.utils.curve.locatorCurve(geoCurve, prefix=prefix + '_geoCrv') # generate reference curve refCurve = cmds.rebuildCurve(baseCurve, ch=1, s=precsion, d=1, rpo=0, rt=0, end=1, kr=0, kcp=0, kep=1, kt=1) refCurveInfo = cmds.createNode('curveInfo', n=prefix + '_ref_curveInfo') cmds.connectAttr(refCurve + '.worldSpace[0]', refCurveInfo + '.inputCurve', f=True) refCurveLocs = [] for i in range(precsion + 1): refNull = cmds.group(em=True, n=prefix + '_ref' + str(i) + '_null') cmds.connectAttr(refCurveInfo + '.controlPoints[' + str(i) + ']', refNull + '.t') refCurveLocs.append(refNull) # Locator Constraints for i in range(precsion + 1): cmds.pointConstraint(refCurveLocs[i], geoCurveLocs[i]) cmds.geometryConstraint(geo, geoCurveLocs[i]) # fitBspline bSpline = cmds.fitBspline(geoCurve, ch=1)
def buildwithMesh(*args): if cmds.window("dynamo_locators", exists=True): cmds.deleteUI("dynamo_locators") if cmds.window("dupSpecialX", exists=True): cmds.deleteUI("dupSpecialX") if cmds.window("dupSpecialY", exists=True): cmds.deleteUI("dupSpecialY") if cmds.window("dupSpecialZ", exists=True): cmds.deleteUI("dupSpecialZ") #/joints herstellen/ locatorListe=cmds.ls(selection=True) listLaenge=len(locatorListe) if listLaenge>4: firstLocator=locatorListe[0] queryFirstLocatorPos=cmds.xform(firstLocator,translation=True,q=True) createController=cmds.circle( nr=(0, 1, 0), c=(queryFirstLocatorPos),r=10,d=1,s=6,n="root_Controller") centerPivotController=cmds.xform(createController,cp=True) cmds.makeIdentity(createController,apply=True, t=1, r=1, s=1, n=0) jointList=[] for i in locatorListe: queryLocPos=cmds.xform(i,translation=True,q=True) cmds.select(clear=True) createJoint=cmds.joint(p=(queryLocPos)) jointList.append(createJoint) cmds.select(clear=True) print jointList #parenting root_Joint to root_Controller mainController=createController #listJoint=cmds.ls(type="joint") firstJoint=jointList[0] pointConstraint=cmds.pointConstraint(mainController,firstJoint,mo=True) orientConstraint=cmds.orientConstraint(mainController,firstJoint,mo=True) cmds.select(clear=True) #/joints parenting/ #jointListe = cmds.ls(type = "joint",v=True) for i, inhalt in enumerate(jointList): # Break Loop if i == 0: continue vorheriges = jointList[i-1] aktuelles = inhalt cmds.parent(aktuelles, vorheriges) cmds.select(clear=True) #/Query Start-End-Number/ queryStartNumber=cmds.textField('startLoc', text=True, q=True) print queryStartNumber queryEndNumber=cmds.textField('endLoc', text=True, q=True) print queryEndNumber start=int(queryStartNumber) end=int(queryEndNumber) #/create Curve/ #jointListe = cmds.ls(type = "joint",v=True) endJoint=len(jointList) jointListwitoutfirst=jointList[start:end] jnListlaenge=len(jointListwitoutfirst) if jnListlaenge>0: curve_degree = 3 jointPos=[] for i in jointListwitoutfirst: queryJnPos=cmds.xform(i, ws=True,translation=True,query=True) jointPos.append(queryJnPos) #print jointPos cvCurve=cmds.curve(d=curve_degree,p=jointPos,ws=True,n="Curve1") epCurve=cmds.fitBspline( ch=1, tol=0.0,n="Original_Curve") cmds.rename("Original_Curve","DynamoOrgCurve") cmds.delete(cvCurve) #/make dynamic curve/ mel.eval('makeCurvesDynamicHairs %d %d %d' % (True, False, True)) #/iksplineHAndle/ sel=cmds.ls(type="joint",v=True) startjoint=jointList[start] endeffector=jointList[end] #print startjoint, endeffector ikSplineHandle=cmds.ikHandle( n="dynamoIkHandle",sj=startjoint, ee=endeffector,solver='ikSplineSolver', p=2, c="curve1",tws="linear",pcv=True,ccv=False,snc=False) renameiKHandleCurve=cmds.rename("curve1","NewDynamoCurve") NewDyCurve=renameiKHandleCurve #/change follicle point lock/ querypointLockOptionMenu=cmds.optionMenu("pointLockOptionMenu",q=True,value=True)[0] print querypointLockOptionMenu pointLock=int(querypointLockOptionMenu) follicleList=cmds.ls("follicle1") for o in follicleList: setPointLockBase=cmds.setAttr(o+".pointLock", pointLock) cmds.rename("follicle1","DynamoFollicle") #/hide/ #cmds.hide( cmds.ls( type="joint" ) ) #/skin/ addBodyMesh = cmds.textField('SMesh', text=True, query=True) cmds.skinCluster( addBodyMesh, jointList[start:end],tsb=True,nw=3,mi=7,dr=10.0,ih=True ) #/renaming Joints/ jointListe = cmds.ls(type = "joint",v=True) rootJoint=jointList[0] endJoint=jointList [0-1] #print endJoint endNewName="end_Joint" rootNewName="root_Joint" cmds.rename(rootJoint,rootNewName) cmds.rename(endJoint,endNewName) count = 1 #/cleaning and parenting/ cmds.parent("hairSystem"+count+"Follicles","root_Joint") count +=1 cmds.hide("DynamoOrgCurve") cmds.select(clear=True) Data=cmds.group(NewDyCurve,ikSplineHandle,"hairSystem1","hairSystem1OutputCurves",w=True,n="Data") cmds.parent("effector1","end_Joint") cmds.select(clear=True) hideIkHandle=cmds.hide("dynamoIkHandle") cmds.select(clear=True) cmds.hide(cmds.ls(type="locator")) cmds.select(clear=True) else: cmds.warning("Select Locators")