Last active
June 14, 2024 07:24
-
-
Save chris-lesage/c0b8365a9742c0c990f3a65d55eb1a46 to your computer and use it in GitHub Desktop.
This is a test mGear Shifter POST script that shows how to access the stepDict and all of its information. It's a WIP meant to also act as documentation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mgear.shifter.custom_step as cstp | |
''' | |
This is a test mGear Shifter POST script that shows how to access the stepDict and all of its information. | |
It's a WIP meant to also act as documentation. | |
I'll continue to update it, as I discover more. And hopefully include some of this information in the official mGear docs. | |
Chris Lesage - chris@rigmarolestudio.com | |
Justin Pedersen - justin@tcgcape.co.za | |
Jascha Wohlkinger - jwohlkinger@gmail.com | |
Big thanks to Jascha Wohlkinger and Justin Pedersen at Triggerfish for helping get this started! | |
''' | |
class CustomShifterStep(cstp.customShifterMainStep): | |
def __init__(self): | |
self.name = "test_stepDict" | |
def run(self, stepDict): | |
stepDict["mgearRun"].__dict__ # This is a way you can inspect properties of a class. | |
stepDict["mgearRun"].components["arm_L0"] # how to get at an individual component. | |
# Loop through all the components in the scene! | |
for key, component in stepDict["mgearRun"].components.items(): | |
# gain access to component settings | |
print(key) # This is the component key in stepDict["mgearRun"].components eg. "arm_L0" | |
print(component) # This is the Component object that has all the following attributes: | |
print('options', component.options) # gets all the top level guide options | |
print('settings', component.settings) # the individual component settings, like maxstretch, upvrefarray, etc. | |
print(component.settings["comp_type"]) # <--- Gets the name of the component type. eg. 'arm_ms_2jnt_01' | |
print('name', component.name) # The given name. eg "arm" in arm_L0 | |
print('side', component.side) # eg. "L" in arm_L0 | |
print('index', component.index) # eg. "0" in arm_L0 | |
print('model', component.model) # the top rig group, "model" because XSI | |
print('connections', component.connections) # TODO: information and memory address of connections | |
print('setupWS', component.setupWS) # TODO: returns the "setup" group, but no idea what that is for. | |
print('size', component.size) # TODO: Not sure what this refers to | |
print('color_fk', component.color_fk) # The color index from the guide settings. I guess you can override this? | |
print('color_ik', component.color_ik) # The color index from the guide settings. I guess you can override this? | |
print('negate', component.negate) # TODO: returns True or False | |
print('n_sign', component.n_sign) # returns '' if negate is False and '-' if True | |
print('n_factor', component.n_factor) # returns 1 if negate is False and -1 if True | |
print('groups', component.groups) # returns a dictionary of items of the component | |
# If no joints exist, there will be no deformers key. | |
# So instead of calling the dictionary key component.groups["deformers"] use .get() to avoid KeyError. | |
# If it is empty, it will return None | |
print(component.groups.get("deformers")) # access to joints in the component | |
print(component.groups.get("componentsRoots")) # The _root of the component | |
print(component.groups.get("controllers")) # All the controllers in the component | |
print('subGroups', component.subGroups) #TODO: No idea. Always empty in my tests. | |
print('controlers', component.controlers) # This always seems to return an empty list. Use component.groups.get("controllers") instead, I guess. | |
print('relatives', component.relatives) #TODO. eg. {'elbow': nt.Transform(u'arm_L0_div5_loc'), 'wrist': nt.Transform(u'arm_L0_div10_loc')} | |
print('jointRelatives', component.jointRelatives) # The joint index as a dictionary. eg. {'elbow': 5, 'wrist': 10, 'root': 0, 'eff': -1} | |
print('controlRelatives', component.controlRelatives) # A key dictionary of controllers. eg. {'elbow': nt.Transform(u'arm_L0_fk1_ctl'), 'wrist': nt.Transform(u'arm_L0_fk2_ctl)} | |
print('aliasRelatives', component.aliasRelatives) #TODO: arm is {'eff': 'hand'} or control_01 is {'root': 'ctl'} | |
print('jnt_pos', component.jnt_pos) # TODO A list of lists [[transform, 0], [transform, 1], [transform, 2], [transform, 'end']] | |
print('jointList', component.jointList) # returns the same as component.groups.get("deformers"). A list of all joints in the component. [] if no joints. | |
print('transform2Lock', component.transform2Lock) #TODO: I guess a list of nodes that will get locked | |
print('stepMethods', component.stepMethods) #TODO: Unsure yet. | |
# Example snippet: Get all components that are named "arm". | |
allArms = [ | |
(key, component) for key, component | |
in stepDict["mgearRun"].components.items() | |
if component.name == 'arm' | |
] | |
for key, component in allArms: | |
print(key) | |
print(component.settings) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment