def curve_through_points(**kwargs): selection_points = pm.ls(selection=True) curve_name = kwargs.get("curve_name", "") curve_degree = kwargs.get("curve_degree", 1) points_locations = kwargs.get("position_list", []) pm.select(clear=True) current_curve = pm.curve(degree = curve_degree, worldSpace=True, point = points_locations) pm.rename(current_curve, curve_name) return None
def makePoleVector(self, constrain=True): iks = pm.ls(selection = True ) originalSelection = iks locators = [] for ik in iks: loc = pm.spaceLocator() pm.rename( loc, 'poleVectorTarget' ) pm.parent( loc, ik ) ik.poleVectorX >> loc.translateX ik.poleVectorY >> loc.translateY ik.poleVectorZ >> loc.translateZ loc.translateX.disconnect() loc.translateY.disconnect() loc.translateZ.disconnect() pm.parent( loc, world=True ) if constrain==True: pm.poleVectorConstraint( loc, ik, weight=1 )
def set_new_name(self, **kwargs): """ set new name to the node passed """ cur_nd = kwargs.get("cur_nd", None) nd_nm = kwargs.get("nd_nm", None) replace_to = kwargs.get("replace_to", None) id_val = kwargs.get("id_val", None) flag = False pm.rename(cur_nd, "TEMP_NODE_NAME") if pm.objExists(nd_nm): if replace_to: nd_nm = nd_nm.replace(replace_to, str(id_val) + replace_to) else: nd_nm = nd_nm + id_val flag = True pm.rename(cur_nd, nd_nm) return flag
def createExpression(self, camera, ctrl): shakeTransform = camera.name() + '_Shake' exp = ''' {ctrl}.time = time;\n float $time = {ctrl}.time; float $timeScale = {ctrl}.timeScale; $time = $time * $timeScale; float $offset = {ctrl}.timeOffset; float $ampl1 = {ctrl}.shakeAmplitude1; float $freq1 = {ctrl}.shakeFrequency1; float $ampl2 = {ctrl}.shakeAmplitude2; float $freq2 = {ctrl}.shakeFrequency2; float $shakeTrX = {ctrl}.shakeTranslateX; float $shakeTrY = {ctrl}.shakeTranslateY; float $shakeTrZ = {ctrl}.shakeTranslateZ; float $shakeRtX = {ctrl}.shakeRotateX; float $shakeRtY = {ctrl}.shakeRotateY; float $shakeRtZ = {ctrl}.shakeRotateZ; float $noise1X = {ctrl}.noise1X = noise( ($time + $offset * 1) * $freq1 ) * $ampl1; float $noise1Y = {ctrl}.noise1Y = noise( ($time + $offset * 2) * $freq1 ) * $ampl1; float $noise1Z = {ctrl}.noise1Z = noise( ($time + $offset * 3) * $freq1 ) * $ampl1; float $noise2X = {ctrl}.noise2X = noise( ($time + $offset * 1) * $freq2 ) * $ampl2; float $noise2Y = {ctrl}.noise2Y = noise( ($time + $offset * 2) * $freq2 ) * $ampl2; float $noise2Z = {ctrl}.noise2Z = noise( ($time + $offset * 3) * $freq2 ) * $ampl2; float $shakeScale = {ctrl}.shakeScale;\n {shakeTransform}.tx = ($noise1X + $noise2X) * $shakeTrX * $shakeScale; {shakeTransform}.ty = ($noise1Y + $noise2Y) * $shakeTrY * $shakeScale; {shakeTransform}.tz = ($noise1Z + $noise2Z) * $shakeTrZ * $shakeScale; {shakeTransform}.rx = ($noise1X + $noise2X) * $shakeRtX * $shakeScale; {shakeTransform}.ry = ($noise1Y + $noise2Y) * $shakeRtY * $shakeScale; {shakeTransform}.rz = ($noise1Z + $noise2Z) * $shakeRtZ * $shakeScale; '''.format(ctrl=ctrl, shakeTransform=shakeTransform) exp = textwrap.dedent(exp) expressionNode = pm.expression(s=exp, ae=1, uc='all', o=ctrl, n=(camera + "_Expression")) self.expression = expressionNode uitConvertsion = expressionNode.outputs(type="unitConversion") for uit in uitConvertsion: pm.rename(uit.name(), self.camera.name() + '_' + uit.name()) self.extNode.extend(uitConvertsion) return expressionNode
def rsPhysicalLight(): mel.eval('redshiftCreateLight("RedshiftPhysicalLight")') light = ls(selection=True)[0] setAttr(light + '.colorMode', 1) setAttr(light + '.intensity', 10) setAttr(light + '.areaVisibleInRender', 0) locator = spaceLocator() move(locator, (0, 0, -1)) setAttr(locator + '.inheritsTransform', 0) locator.setParent(light) aim = aimConstraint(locator, light) setAttr(aim + '.aimVector', (0, 0, -1)) position = autoPlace() move(light, position, relative=True) move(locator, position, relative=True) rename(locator, '{}_aim'.format(light)) modelEditor('modelPanel4', e=True, lights=True, locators=True)
## this script based on an idea originally found at: ## magnus-olsson.se import pymel.all as pm import traceback import os fileNodes = pm.ls(textures=True) ## or alternatively, just selected file node # fileNodes = pm.ls(textures=True, selection=True) for f in fileNodes: try: fileNameFull = f.fileTextureName.get() fileNameBase = os.path.basename(fileNameFull) fileName, fileExt = os.path.splitext(fileNameBase) pm.rename(f, fileName ) except: print( traceback.format_exc() )
def setup_ik_spline(**kwargs): curve = kwargs.get("curve", None) joint_chain = kwargs.get("joint_chain", None) auto_curve = kwargs.get("auto_curve", True) use_curve = kwargs.get("use_curve", None) spans = kwargs.get("number_of_spans", 4) ctrl_jnts = kwargs.get("num_control_joints", 3) ik_name = kwargs.get("ik_name", "ikHandle") scale_stretch = kwargs.get("scale_stretch", False) create_dense_chain = kwargs.get("dense_chain", False) dense_division = kwargs.get("dense_chain_divisions", 3) auto_simplify = kwargs.get("auto_simplify_curve", False) stretch_exp = kwargs.get("stretch_exp", False) global_scale_check = kwargs.get("global_scale_check", False) global_scale_attr = kwargs.get("global_scale_attr", None) pm.select(joint_chain, hierarchy=True) joint_chain = pm.ls(selection=True) if not isinstance(joint_chain[0], pm.Joint): pm.displayInfo("selection should be of type joint") return None if len(joint_chain) < 2: pm.displayInfo("Chain should consist of more than one joint") return None if (global_scale_check): if (global_scale_attr is None): pm.displayInfo("Please input global scale attribute") return None else: obj = global_scale_attr.split(".")[0] global_attr = global_scale_attr.split(".")[1] check_global_attr = pm.attributeQuery(global_attr, node=obj, exists=True) if not check_global_attr: pm.displayInfo("Invalid global scale attribute") return None start_jnt = joint_chain[0] end_joint = joint_chain[-1] if create_dense_chain: rep_chain = pm.duplicate(joint_chain) start_jnt = rep_chain[0] end_joint = rep_chain[-1] dense_chain(joints=rep_chain, joints_inbetween=dense_division) rep_chain.append(end_joint) for index in range(len(joint_chain)): pm.parentConstraint(rep_chain[index], joint_chain[index], maintainOffset=False) #pm.scaleConstraint(rep_chain[index], joint_chain[index], maintainOffset=False) pm.connectAttr( str(rep_chain[index]) + ".scale", str(joint_chain[index]) + ".scale") pm.select(start_jnt, hierarchy=True) new_chain = pm.ls(selection=True) crv = "" #print "START", start_jnt #print "END",end_joint if auto_curve: ik_handle, eff, crv = pm.ikHandle(startJoint=start_jnt, createCurve=auto_curve, solver="ikSplineSolver", numSpans=spans, endEffector=end_joint, simplifyCurve=auto_simplify) else: crv = pm.PyNode(use_curve) ik_handle, eff = pm.ikHandle(startJoint=start_jnt, curve=use_curve, solver="ikSplineSolver", endEffector=end_joint, createCurve=False) crv.inheritsTransform.set(0) pm.rename(ik_handle, ik_name + "IK_Handle") pm.rename(crv, ik_name + "IK_Curve") ik_curve_shp = crv.getShape() crv_info_node = pm.createNode("curveInfo") pm.connectAttr(ik_curve_shp + ".worldSpace", crv_info_node + ".inputCurve") ''' if stretch_exp: if create_dense_chain: stretch_expression(joints = new_chain, curve_info_node = crv_info_node, connect_scale = scale_stretch, expression_name = ik_name+"_stretch_expression") else: stretch_expression(joints = joint_chain, curve_info_node = crv_info_node, connect_scale = scale_stretch, expression_name = ik_name+"_stretch_expression") ''' if ctrl_jnts: if ctrl_jnts == 1: print "Minimum 2 joints needed as controllers" print "skipping control joint creation process" pm.displayInfo("Minimum 2 joints needed as controllers") else: ctrl_jnts = joints_along_curve(number_of_joints=ctrl_jnts, curve=crv, bind_curve_to_joint=True) pm.select(clear=True) ctr_jnt_gp = pm.group(ctrl_jnts, name="control_joints") #print "JNT NAME", ctr_jnt_gp if stretch_exp: pm.addAttr(ctrl_jnts[-1], longName="Stretch", attributeType="enum", enumName="off:on", keyable=True) print "ATTRIBUTE TO", str(ctrl_jnts[-1]) if create_dense_chain: stretch_expression(joints=new_chain, curve_info_node=crv_info_node, connect_scale=scale_stretch, expression_name=ik_name + "_stretch_expression", ctrl_attr=str(ctrl_jnts[-1]) + ".Stretch", glbl_scl_stat=global_scale_check, glbl_scl_attr=global_scale_attr) else: stretch_expression(joints=joint_chain, curve_info_node=crv_info_node, connect_scale=scale_stretch, expression_name=ik_name + "_stretch_expression", ctrl_attr=str(ctrl_jnts[-1]) + ".Stretch", glbl_scl_stat=global_scale_check, glbl_scl_attr=global_scale_attr) final_group = pm.group(name=ik_name + "_ik_group", empty=True) pm.parent(joint_chain[0], final_group) pm.parent(crv, final_group) pm.parent(ik_handle, final_group) if ctrl_jnts > 1: pm.parent(ctr_jnt_gp, final_group) if create_dense_chain: pm.select(clear=True) dense_grp = pm.group(start_jnt, name="dense_chain_group") pm.parent(dense_grp, final_group) return None
def createCtrl(self, name): #cameraName = camera[0].name() cameraShape = self.camera.getShape() # 그룹 리깅 constraint = pm.group(n=name + "_constraint", em=True) offset = pm.group(n=name + "_offset") shakeTransform = pm.group(n=name + "_Shake") offsetTz = pm.group(n=name + "_offsetTz") offsetTy = pm.group(n=name + "_offsetTy") offsetTx = pm.group(n=name + "_offsetTx") tz = pm.group(n=name + "_tz") rz = pm.group(n=name + "_rz") rx = pm.group(n=name + "_rx") ry = pm.group(n=name + "_ry") ctrl = pm.group(n=name + "_Ctrl") pm.setAttr(ctrl + ".displayHandle", 1) pm.setAttr(ctrl + ".overrideEnabled", 1) pm.setAttr(ctrl + ".overrideColor", 7) #dark_green # Display dispGrp = pm.group(n=name + "_Template_Grp", em=1) pm.parent(dispGrp, ctrl) pm.setAttr(dispGrp + ".overrideEnabled", 1) pm.setAttr(dispGrp + ".overrideDisplayType", 1) pm.setAttr(dispGrp + ".overrideColor", 7) #dark_green dispNodeList = [] dispNodeList.extend(self.displayConnect([ctrl, tz])) dispNodeList.extend(self.displayConnect([tz, offsetTx])) dispNodeList.extend(self.displayConnect([offsetTx, offsetTy])) dispNodeList.extend(self.displayConnect([offsetTy, offsetTz])) # Outline for dispNode in dispNodeList: dispNode.rename(name + '_' + dispNode.name()) pm.parent(dispNodeList, dispGrp) # Add attribute # Camera attribute pm.addAttr(ctrl, ln="Camera", en="Option:", at="enum") pm.setAttr(ctrl + ".Camera", e=1, channelBox=True) pm.addAttr(ctrl, ln="focalLength", dv=35, at='double', nn="FocalLength (mm)", keyable=True) pm.addAttr(ctrl, ln="overscan", dv=1, at='double', nn="Overscan", keyable=True) pm.addAttr(ctrl, ln="frameRange", at='double2', nn="Frame Range (frame)") pm.addAttr(ctrl, ln="startFrame", p='frameRange', at='double', nn="Start Frame", keyable=True) pm.addAttr(ctrl, ln="endFrame", p='frameRange', at='double', nn="End Frame", keyable=True) # Tumble attribute pm.addAttr(ctrl, ln="Tumble", en="Option:", at="enum") pm.setAttr(ctrl + ".Tumble", e=1, channelBox=True) pm.addAttr(ctrl, ln="tumbleTranslateZ", at='double', nn="Tumble Translate Z", keyable=True) pm.addAttr(ctrl, ln="tumbleRotate", at='double3', nn="Tumble Rotate") pm.addAttr(ctrl, ln="tumbleRotateX", p='tumbleRotate', at='double', nn="Tumble Rotate X", keyable=True) pm.addAttr(ctrl, ln="tumbleRotateY", p='tumbleRotate', at='double', nn="Tumble Rotate Y", keyable=True) pm.addAttr(ctrl, ln="tumbleRotateZ", p='tumbleRotate', at='double', nn="Tumble Rotate Z", keyable=True) # Shake attribute pm.addAttr(ctrl, ln="Shake", en="Option:", at="enum") pm.setAttr(ctrl + ".Shake", e=1, channelBox=True) pm.addAttr(ctrl, ln="time", keyable=False, at='double', nn="Shake Time (second)") pm.addAttr(ctrl, ln="timeOffset", keyable=False, at='double', nn="Shake Time Offset (second)") pm.addAttr(ctrl, ln="shake1", at='double2', nn=u"Shake 1st (진폭, 주기)") pm.addAttr(ctrl, ln="shakeAmplitude1", p='shake1', at='double', nn=u"Shake 1st (진폭)", keyable=True) pm.addAttr(ctrl, ln="shakeFrequency1", p='shake1', at='double', nn=u"Frequency 1st (주기)", keyable=True) pm.addAttr(ctrl, ln="noise1", at='double3', nn="Shake Noise 1st") pm.addAttr(ctrl, ln="noise1X", p='noise1', at='double', nn="Shake Noise 1 X") pm.addAttr(ctrl, ln="noise1Y", p='noise1', at='double', nn="Shake Noise 1 Y") pm.addAttr(ctrl, ln="noise1Z", p='noise1', at='double', nn="Shake Noise 1 Z") pm.addAttr(ctrl, ln="shake2", at='double2', nn=u"Shake 2nd (진폭, 주기)") pm.addAttr(ctrl, ln="shakeAmplitude2", p='shake2', at='double', nn=u"Shake 2nd (진폭)", keyable=True) pm.addAttr(ctrl, ln="shakeFrequency2", p='shake2', at='double', nn=u"Frequency 2nd (주기)", keyable=True) pm.addAttr(ctrl, ln="noise2", at='double3', nn="Shake Noise 2nd") pm.addAttr(ctrl, ln="noise2X", p='noise2', at='double', nn="Shake Noise 2 X") pm.addAttr(ctrl, ln="noise2Y", p='noise2', at='double', nn="Shake Noise 2 Y") pm.addAttr(ctrl, ln="noise2Z", p='noise2', at='double', nn="Shake Noise 2 Z") pm.addAttr(ctrl, ln="shakeTranslate", at='double3', nn="Shake Translate") pm.addAttr(ctrl, ln="shakeTranslateX", p='shakeTranslate', at='double', nn="Shake Translate X", keyable=True) pm.addAttr(ctrl, ln="shakeTranslateY", p='shakeTranslate', at='double', nn="Shake Translate Y", keyable=True) pm.addAttr(ctrl, ln="shakeTranslateZ", p='shakeTranslate', at='double', nn="Shake Translate Z", keyable=True) pm.addAttr(ctrl, ln="shakeRotate", at='double3', nn="Shake Rotate") pm.addAttr(ctrl, ln="shakeRotateX", p='shakeRotate', at='double', nn="Shake Rotate X", keyable=True) pm.addAttr(ctrl, ln="shakeRotateY", p='shakeRotate', at='double', nn="Shake Rotate Y", keyable=True) pm.addAttr(ctrl, ln="shakeRotateZ", p='shakeRotate', at='double', nn="Shake Rotate Z", keyable=True) pm.addAttr(ctrl, ln="shakeScale", at='double', dv=1.0, keyable=True) pm.addAttr(ctrl, ln="timeScale", at='double', dv=1.0, keyable=True) # Offset attribute pm.addAttr(ctrl, ln="Offset", en="Option:", at="enum") pm.setAttr(ctrl + ".Offset", e=1, channelBox=True) pm.addAttr(ctrl, ln="offsetTranslate", at='double3', nn="Offset Translate") pm.addAttr(ctrl, ln="offsetTranslateX", p='offsetTranslate', at='double', nn="Offset Translate X", keyable=True) pm.addAttr(ctrl, ln="offsetTranslateY", p='offsetTranslate', at='double', nn="Offset Translate Y", keyable=True) pm.addAttr(ctrl, ln="offsetTranslateZ", p='offsetTranslate', at='double', nn="Offset Translate Z", keyable=True) pm.addAttr(ctrl, ln="offsetRotate", at='double3', nn="Offset Rotate") pm.addAttr(ctrl, ln="offsetRotateX", p='offsetRotate', at='double', nn="Offset Rotate X", keyable=True) pm.addAttr(ctrl, ln="offsetRotateY", p='offsetRotate', at='double', nn="Offset Rotate Y", keyable=True) pm.addAttr(ctrl, ln="offsetRotateZ", p='offsetRotate', at='double', nn="Offset Rotate Z", keyable=True) # Display attribute pm.addAttr(ctrl, ln="Display", en="Option:", at="enum") pm.setAttr(ctrl + ".Display", e=1, channelBox=True) pm.addAttr(ctrl, ln="cameraScale", dv=1, at='double', nn="Camera Scale", keyable=True) pm.addAttr(ctrl, en="off:on:", nn="Display Ctrler", ln="displayCtrler", keyable=1, at="enum", dv=1) # Connect Attr pm.connectAttr(ctrl + ".cameraScale", name + ".sx") pm.connectAttr(ctrl + ".cameraScale", name + ".sy") pm.connectAttr(ctrl + ".cameraScale", name + ".sz") pm.connectAttr(ctrl + ".focalLength", cameraShape + ".focalLength") pm.connectAttr(ctrl + ".overscan", cameraShape + ".overscan") pm.connectAttr(ctrl + ".tumbleRotateX", rx + ".rx") pm.connectAttr(ctrl + ".tumbleRotateY", ry + ".ry") pm.connectAttr(ctrl + ".tumbleRotateZ", rz + ".rz") pm.connectAttr(ctrl + ".tumbleTranslateZ", tz + ".tz") pm.connectAttr(ctrl + ".offsetTranslateX", offsetTx + ".tx") pm.connectAttr(ctrl + ".offsetTranslateY", offsetTy + ".ty") pm.connectAttr(ctrl + ".offsetTranslateZ", offsetTz + ".tz") pm.connectAttr(ctrl + ".offsetRotate", offset + ".r") pm.connectAttr(ctrl + ".displayCtrler", dispGrp + ".v") # Lock and Hide unused attr attrList = [ "_ry.tx", "_ry.ty", "_ry.tz", "_ry.rx", "_ry.rz", "_ry.sx", "_ry.sy", "_ry.sz", "_ry.v", "_rx.tx", "_rx.ty", "_rx.tz", "_rx.ry", "_rx.rz", "_rx.sx", "_rx.sy", "_rx.sz", "_rx.v", "_rz.tx", "_rz.ty", "_rz.tz", "_rz.rx", "_rz.ry", "_rz.sx", "_rz.sy", "_rz.sz", "_rz.v", "_tz.tx", "_tz.ty", "_tz.rx", "_tz.ry", "_tz.rz", "_tz.sx", "_tz.sy", "_tz.sz", "_tz.v", "_offsetTx.ty", "_offsetTx.tz", "_offsetTx.rx", "_offsetTx.ry", "_offsetTx.rz", "_offsetTx.sx", "_offsetTx.sy", "_offsetTx.sz", "_offsetTx.v", "_offsetTy.tx", "_offsetTy.tz", "_offsetTy.rx", "_offsetTy.ry", "_offsetTy.rz", "_offsetTy.sx", "_offsetTy.sy", "_offsetTy.sz", "_offsetTy.v", "_offsetTz.tx", "_offsetTz.ty", "_offsetTz.rx", "_offsetTz.ry", "_offsetTz.rz", "_offsetTz.sx", "_offsetTz.sy", "_offsetTz.sz", "_offsetTz.v", "_offset.sx", "_offset.sy", "_offset.sz", "_offset.v", "_Ctrl.sx", "_Ctrl.sy", "_Ctrl.sz" ] for attr in attrList: pm.setAttr(name + attr, lock=True, channelBox=False, keyable=False) pm.setAttr(cameraShape + ".orthographic", lock=False, channelBox=False, keyable=True) pm.setAttr(cameraShape + ".orthographicWidth", lock=False, channelBox=False, keyable=True) # Constraint camera const = pm.parentConstraint(constraint, self.camera, n=name + '_parentConstraint') pm.setAttr(const + ".nds", lock=True, channelBox=False, keyable=False) pm.setAttr(const + ".int", lock=True, channelBox=False, keyable=False) pm.setAttr(const + ".w0", lock=True, channelBox=False, keyable=False) pm.parent(const, ctrl) # Add and Connect message attr = "camera" nodes = [self.camera, ctrl] for node in nodes: if node.hasAttr(attr): node.deleteAttr(attr) pm.addAttr(node, ln=attr, multi=1, attributeType="message", indexMatters=False) for node in nodes: for i in range(0, 2): pm.connectAttr('{}.message'.format(nodes[i].name()), '{}.{}[{}]'.format(node.name(), attr, str(i)), f=1) # Return self.ctrl = ctrl uitConvertsion = self.ctrl.outputs(type="unitConversion") for uit in uitConvertsion: pm.rename(uit.name(), name + '_' + uit.name()) del self.extNode[:] self.extNode.extend([ constraint, offset, shakeTransform, offsetTz, offsetTy, offsetTx, tz, rz, rx, ry, ctrl ]) self.extNode.extend(dispNodeList) self.extNode.extend(uitConvertsion) pm.select(self.ctrl, r=1) return ctrl
def refreshArsenalPass(self, progressBarUpdate = None): allRenderLayers = pm.RenderLayer.listAllRenderLayers() for myRenderLayer in allRenderLayers: arsenalPassName = myRenderLayer.name() + '_arsenalPass' aresenalConnected = myRenderLayer.listConnections(destination=True, source=False, type='arsenalPass') ajustements = pm.editRenderLayerAdjustment(myRenderLayer, query=True, layer=True) if len(aresenalConnected) == 0: if not pm.objExists(arsenalPassName): pm.createNode('arsenalPass', name=arsenalPassName) pm.lockNode(arsenalPassName, lock=True) pm.connectAttr(myRenderLayer.name() + '.message', arsenalPassName + '.passName', force=True) elif str(aresenalConnected[0]) != arsenalPassName: pm.lockNode(aresenalConnected[0], lock=False) pm.rename(aresenalConnected[0], arsenalPassName) pm.lockNode(arsenalPassName, lock=True) self.passName[myRenderLayer].passName = myRenderLayer.name() attributesFastArsenal = ['lightSelectAllNormal', 'lightSelectAllDiffuse', 'lightSelectAllRaw', 'lightSelectAllSpecular', 'vrayLambert', 'multimatteMaskName', 'vrayMaterialID', 'vrayProxyObjectID'] attributesFastVray = ['giOn', 'primaryEngine', 'secondaryEngine', 'imap_detailEnhancement', 'aoOn', 'globopt_mtl_glossy', 'globopt_mtl_reflectionRefraction', 'globopt_mtl_doMaps', 'globopt_light_doShadows', 'aaFilterOn', 'globopt_geom_displacement', 'cam_mbOn', 'cam_dofOn', 'cam_overrideEnvtex', 'sys_distributed_rendering_on'] attributesConnectionArsenal = ['passMembers', 'blackHoleMembers', 'blackHoleMembersReceiveShd', 'giMembersGenerate', 'giMembersReceive', 'primaryMembersOff', 'reflectionMembersOff', 'refractionMembersOff', 'shadowCastsMembersOff', 'lightSelectNormalMembers', 'lightSelectDiffuseMembers', 'lightSelectRawMembers', 'lightSelectSpecularMembers'] self.multiMatteAttributes(myRenderLayer=myRenderLayer, attributesConnectionArsenal=attributesConnectionArsenal) for (i, attribut,) in enumerate(attributesFastArsenal): if progressBarUpdate is not None: progressBarUpdate(numStep=100, value=i, text='Pass ' + myRenderLayer.name() + ' step 2 : init FastArsenal %v of %m ...') self.initAttributes(attribut=attribut, renderPass=myRenderLayer) for (i, attribut,) in enumerate(attributesFastVray): self.initAttributes(attribut=attribut, renderPass=myRenderLayer, fromRenderGlobal=True) if progressBarUpdate is not None: progressBarUpdate(numStep=100, value=i, text='Pass ' + myRenderLayer.name() + ' step 3 : init FastVray %v of %m ...') if myRenderLayer.name() != 'defaultRenderLayer': if ajustements is None or 'vraySettings.' + attribut not in ajustements: self.overrideAttribute(renderPass=myRenderLayer, node=arsenalPassName, attribute=attribut, always=True) else: self.overrideAttribute(renderPass=myRenderLayer, node=arsenalPassName, attribute=attribut, always=False) for (i, attribut,) in enumerate(attributesConnectionArsenal): if progressBarUpdate is not None: progressBarUpdate(numStep=100, value=i, text='Pass ' + myRenderLayer.name() + ' step 4 : init FastConnection %v of %m ...') self.initAttributes(attribut=attribut, renderPass=myRenderLayer, connection=True) if progressBarUpdate is not None: progressBarUpdate(numStep=100, value=100, text='Done...')
def setup_motion_path(self): setup_name = self.get_setup_name() path_name = self.get_path_name() sample_obj = self.get_sample_objects() duplicate_flag = self.get_duplicate_flag() placement_type = self.get_placement_type() division_count = self.get_division_count() if setup_name == self.INVALID_INPUT_FAIL: pm.displayError("Invalid Input Entered for setup name") return None if path_name == self.INVALID_INPUT_FAIL: pm.displayError("Invalid Input Entered for path name") return None if path_name == self.NO_OBJECT_FAIL: pm.displayError("path Curve does not exist") return None if path_name == self.DATA_TYPE_FAIL: pm.displayError("Path can be only Nurb Curves") return None if division_count == self.INVALID_INPUT_FAIL: pm.displayError("Invalid Input Entered for divisions") return None if division_count == self.DATA_TYPE_FAIL: pm.displayError("Divisions can take only integer values") return None if sample_obj == self.NO_OBJECT_FAIL: pm.displayError("Sample Object not found") return None obj_list = [] path_anim_list = [] sel_objs = pm.ls(selection=True) if duplicate_flag: path_name = self.get_duplicate_path(path_crv=path_name) path_name = pm.rename(path_name, setup_name + "_path_CRV") if placement_type == "uniform": obj_list, path_anim_list = self.uniform_distribution( name=setup_name, path=path_name, sample=sample_obj, divisions=division_count) else: if not sel_objs: pm.displayError("No Objects selected") for obj in sel_objs: if not pm.objExists(obj): pm.displayWarning(str(obj), "does not exist") return None obj_list, path_anim_list = self.at_selection( name=setup_name, path=path_name, sample=sample_obj, selection_list=sel_objs) loc_pos = CustomScripts.midPos(selected_items=path_name) loc = pm.spaceLocator(name=setup_name + "_up_loc") pm.xform(loc, translation=loc_pos) control_crv = pm.circle(name=setup_name + "CTRL", normalX=1, normalY=0, normalZ=0) pm.xform(control_crv[0], translation=loc_pos, worldSpace=True) pm.select(clear=True) # add run and speed attributes on parent nurb curve pm.addAttr(control_crv[0], longName="run", attributeType="float", keyable=True) pm.addAttr(control_crv[0], longName="speed", attributeType="float", keyable=True, minValue=0.0, defaultValue=0.5) # edit the existing motion path to assign up locator for mtPth in path_anim_list: pm.pathAnimation(mtPth, edit=True, worldUpType="object", worldUpObject=loc) # parent the setup under the parent nurb curve pm.parent(path_name, control_crv[0]) pm.parent(loc, control_crv[0]) pm.select(clear=True) gp = pm.group(name=setup_name + "GP") pm.xform(gp, translation=loc_pos) pm.select(clear=True) obj_gp = pm.group(obj_list, name=setup_name + "object_GP") pm.parent(control_crv[0], gp) pm.parent(obj_gp, gp) # call to create expression function self.createTreadExpression(mtnPth=path_anim_list, runAttr=str(control_crv[0]) + ".run", speedAttr=str(control_crv[0]) + ".speed", exp_nm=setup_name) return None
## this script based on an idea originally found at: ## magnus-olsson.se import pymel.all as pm import traceback import os fileNodes = pm.ls(textures=True) ## or alternatively, just selected file node # fileNodes = pm.ls(textures=True, selection=True) for f in fileNodes: try: fileNameFull = f.fileTextureName.get() fileNameBase = os.path.basename(fileNameFull) fileName, fileExt = os.path.splitext(fileNameBase) pm.rename(f, fileName) except: print(traceback.format_exc())