Home Website Youtube GitHub

leg_2jnt_freeTangents_01 Pole Vector Spaces Bug

Hello! When i use leg_2jnt_freeTangents_01 and build then my pole vector control dont move for IK_ctl Space, bec use world_ctl. I can fix it in custom step, but i think its need fix for all peolpe. Thanks!


Thanks a lot!
Georgii.

This is custom step for fix that problem

import mgear.shifter.custom_step as cstp


class CustomShifterStep(cstp.customShifterMainStep):
    """Custom Step description
    """

    def setup(self):
        """
        Setting the name property makes the custom step accessible
        in later steps.

        i.e: Running  self.custom_step("refIKRename")  from steps ran after
             this one, will grant this step.
        """
        self.name = "refIKRename"

    def run(self):
        """Run method.

            i.e:  self.mgear_run.global_ctl
                gets the global_ctl from shifter rig build base

            i.e:  self.component("control_C0").ctl
                gets the ctl from shifter component called control_C0

            i.e:  self.custom_step("otherCustomStepName").ctlMesh
                gets the ctlMesh from a previous custom step called
                "otherCustomStepName"

        Returns:
            None: None
        """
        import maya.cmds as mc

        def create_parentConstraint_and_conditions(side='L0'):
            # Define the name of the group based on the provided side.
            group_name = 'leg_{}_upv_cns'.format(side)
            
            # Check and delete existing parentConstraint and associated condition nodes.
            constraint_name = group_name + "_parentConstraint1"
            
            if mc.objExists(constraint_name):
                # Get all source connections to the constraint (this should give us the condition nodes).
                src_connections = mc.listConnections(constraint_name, s=True, d=False)
                
                # Delete associated condition nodes.
                if src_connections:
                    for node in src_connections:
                        if mc.nodeType(node) == "condition" and mc.objExists(node):  # Make sure the node exists
                            mc.delete(node)
                
                # Delete the constraint.
                mc.delete(constraint_name)
            
            # Unlock translate and rotate attributes.
            for axis in ['X', 'Y', 'Z']:
                mc.setAttr(group_name + '.translate' + axis, l=False)
                mc.setAttr(group_name + '.rotate' + axis, l=False)
                
            # Define the name of the group and the target objects for the parentConstraint based on the provided side.
            group_name = 'leg_{}_upv_cns'.format(side)
            targets = [
                'leg_{}_legUpvRef0_jnt'.format(side), 
                'leg_{}_ik_ctl'.format(side), 
                'local_C0_ctl', 
                'global_C0_ctl'
            ]
            
            # Check if the group and the target objects exist in the scene.
            if not mc.objExists(group_name):
                mc.warning("{} doesn't exist in the scene.".format(group_name))
                return
            
            for target in targets:
                if not mc.objExists(target):
                    mc.warning("{} doesn't exist in the scene.".format(target))
                    return
            
            # Create the parentConstraint.
            mc.parentConstraint(targets, group_name, mo=True)
            
            # Set up the condition nodes based on the 'leg_upvref' attribute of the control.
            ctrl_name = 'legUI_{}_ctl'.format(side)
            attr_name = 'leg_upvref'
            
            # Get the number of enum values in the 'leg_upvref' attribute.
            enum_values = mc.attributeQuery(attr_name, node=ctrl_name, listEnum=True)[0].split(':')
            num_values = len(enum_values)
            
            # Create a condition node for each enum value.
            condition_nodes = []
            for i in range(num_values):
                condNode = mc.shadingNode('condition', asUtility=True)
                mc.setAttr(condNode + '.secondTerm', i)
                mc.setAttr(condNode + '.colorIfTrueR', 1)
                mc.setAttr(condNode + '.colorIfFalseR', 0)
                
                # Connect the 'leg_upvref' attribute to the 'firstTerm' of the condition node.
                mc.connectAttr(ctrl_name + '.' + attr_name, condNode + '.firstTerm', f=True)
                
                condition_nodes.append(condNode)
            
            # Connect the 'outputColorR' of the condition nodes to the weights of the parentConstraint.
            constraint_name = group_name + "_parentConstraint1"
            for i, condNode in enumerate(condition_nodes):
                weight_attr = '.{}W{}'.format(targets[i], i)
                mc.connectAttr(condNode + '.outColorR', constraint_name + weight_attr, f=True)
            for axis in ['X', 'Y', 'Z']:
                mc.setAttr(group_name + '.translate' + axis, l=True)
                mc.setAttr(group_name + '.rotate' + axis, l=True)
        # Execute the function
        create_parentConstraint_and_conditions('L0')
        create_parentConstraint_and_conditions('R0')
        return
3 Likes