def add_controller_tag(self, ctl, tagParent): ctt = node.add_controller_tag(ctl, tagParent) if ctt: ni = attribute.get_next_available_index(self.model.rigCtlTags) pm.connectAttr( ctt.message, self.model.attr("rigCtlTags[{}]".format(str(ni))) )
def connect_curve_to_xgen_guide(crv, xgen_description): curv2spline_node = get_curve_to_spline_node(xgen_description) if not curv2spline_node: curv2spline_node = create_curve_guide_setup(xgen_description) if not isinstance(crv, list): crv = [crv] for c in crv: next_idx = attribute.get_next_available_index( curv2spline_node.inputCurves) pm.connectAttr( c.worldSpace, curv2spline_node.attr("inputCurves[{}]".format(str(next_idx))))
def controller_tag_connect(ctt, tagParent): """Summary Args: ctt (TYPE): Teh control tag tagParent (TYPE): The object with the parent control tag """ if pm.controller(tagParent, q=True): tpTagNode = pm.PyNode(pm.controller(tagParent, q=True)[0]) tpTagNode.cycleWalkSibling.set(True) pm.connectAttr(tpTagNode.prepopulate, ctt.prepopulate, f=True) ni = attribute.get_next_available_index(tpTagNode.children) pm.disconnectAttr(ctt.parent) pm.connectAttr(ctt.parent, tpTagNode.attr("children[%s]" % str(ni)))
def create_layer_node(name, affectedElements): """Create a transform node that contain the layer information. Args: name (str): layer name affectedElements (dagNode list): Elements affected by the layer. Only Mesh type is supported Returns: dagNode: layer node """ fullName = name + "_crankLayer" # create node if pm.ls(fullName): pm.displayWarning("{} already exist".format(fullName)) return layer_node = pm.createNode("transform", n=fullName, p=None, ss=True) attribute.lockAttribute(layer_node) # add attrs attribute.addAttribute(layer_node, CRANK_TAG, "bool", False, keyable=False) # this attribute will help to track the edit state to speed up the callback attribute.addAttribute(layer_node, "edit_state", "bool", False, keyable=False) # affected objects layer_node.addAttr("layer_objects", at='message', m=True) layer_node.addAttr("layer_blendshape_node", at='message', m=True) # master envelope for on/off attribute.addAttribute(layer_node, "crank_layer_envelope", "float", value=1, minValue=0, maxValue=1) # create the post-blendshapes nodes for each affected object # connections for x in affectedElements: idx = attribute.get_next_available_index(layer_node.layer_objects) pm.connectAttr(x.message, layer_node.layer_objects[idx]) return layer_node
def create_layer(oSel): """Create new crank layer for shot sculpting Args: oSel (Mesh list): Objects to be included in the layer Returns: dagNode: cranklayer node with all the layer data """ oSel = [x for x in oSel if x.getShapes() and x.getShapes()[0].type() == 'mesh'] if oSel: result = pm.promptDialog(title='Crank Layer Name', message='Enter Name:', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel', text="") if result == 'OK': text = pm.promptDialog(query=True, text=True) name = string.normalize(text) layer_node = create_layer_node(name, oSel) bs_list = create_blendshape_node(name, oSel) for bs in bs_list: layer_node.crank_layer_envelope >> bs.envelope idx = attribute.get_next_available_index( layer_node.layer_blendshape_node) pm.connectAttr(bs.message, layer_node.layer_blendshape_node[idx]) pm.select(oSel) return layer_node