edit: updated the script. it now has a constrain. direct connection wasn’t working
Here a script that can fix the 3bone legs in post custom step.
import mgear.shifter.custom_step as cstp
import pymel.core as pm
class CustomShifterStep(cstp.customShifterMainStep):
def __init__(self):
self.name = "00_fixlegs"
def run(self, stepDict):
"""Run method.
i.e: stepDict["mgearRun"].global_ctl gets the global_ctl from
shifter rig build bas
i.e: stepDict["mgearRun"].components["control_C0"].ctl gets the
ctl from shifter component called control_C0
i.e: stepDict["otherCustomStepName"].ctlMesh gets the ctlMesh
from a previous custom step called "otherCustomStepName"
Arguments:
stepDict (dict): Dictionary containing the objects from
the previous steps
Returns:
None: None
"""
# name of components that needs fixing
list_components = [
"legFront_L0",
"legBack_L0",
"legFront_R0",
"legBack_R0"
]
list_components = [stepDict["mgearRun"].components[i] for i in list_components]
# create new connections to fix the flipping
self.newconnection(list_components)
return
def newconnection(self, fix_list):
# creates a connection from joint local matrix to through transform outmatrix to ctl parent mgearRollSplineKine
for e in fix_list:
# create transform to pass rotateZ value
fixed_e = pm.duplicate(e.tws3_rot, name="{}_tws3_fix".format(e.fullName))
# _div6_loc -> _div9_loc
# list of loc's that need to be fixed
list_loc = [
"_div6_loc",
"_div7_loc",
"_div8_loc",
"_div9_loc"
]
for i in list_loc:
# get the up connection 'mgear_rollSplineKine'
parentlist_loc = pm.listConnections("{}{}".format(e.fullName, i), type="mgear_rollSplineKine")
# ctlParent[3] plug the fix transform in the mgear_rollSplineKine
pm.connectAttr(fixed_e[0].worldMatrix[0], parentlist_loc[0].ctlParent[3] ,force=True)
# get the orient z of the _legBones2_jnt into the fix transform
pm.orientConstraint(pm.PyNode("{}_legBones2_jnt".format(e.fullName)), fixed_e[0], skip=['x','y'], maintainOffset=True, weight=1)