Home Website Youtube GitHub

Accessing Maya sets in post step

Hello :slight_smile:

I am trying to access the Maya sets that get created while building the rig because I need to rename them.

I am trying using stepDict[“mgearRun”].groups, but this seems to return lists of items in the sets, not the sets themselves.

Anybody knows how to access the sets?

Thanks in advance! :slight_smile:

Hi Carlos,

This is everything I know about this. There might be a better way.


When Shifter creates the sets, it also connects a message attribute from the ObejctSet to an attribute on your main rig group. So you can find all the sets this way:

# List all the selection sets of the rig. This returns the PyNode of the ObjectSet nodes.
# model is the top parent of the entire rig.
rig = stepDict['mgearRun'].model
for each in rig.rigGroups.inputs():
    print(each)

I don’t know how you would find a specific one, except by name, or querying what types of objects are in the set. The order might be the same every time. So “controllers” might always be 1. deformers might always be 3. But I’m not sure.

# This MIGHT always be the controllers set, if the order is always the same.
pm.PyNode('rig').rigGroups[1].get()
# Or in the stepDict
stepDict['mgearRun'].model.rigGroups[1].get()

This code is in mgear_X.X/scripts/mgear/shifter/__init__.py and you could add a key to the dictionary that actually stores the PyNode to the ObjectSet itself. That could be a nice feature request. I’m adding it to my long list of ideas.



A bunch of other stuff:

stepDict["mgearRun"].groups is a dictionary containing the groups of objects. The key is the group name, and the value is the members of the group. The name of the group and the name of the ObjectSet node do not match.

By default, these 3 show up in the dictionary of groups:

"controllers"
"componentsRoots"
"deformers"

That isn’t the actual name of the sets. When the sets are created, it format the name as "[rig name]_[group name]_grp". Your rig name can be found, so you could recreate the set name, but that is not very robust:

rig = stepDict['mgearRun'].model
rig.rig_name.get()
import mgear.shifter.custom_step as cstp

class CustomShifterStep(cstp.customShifterMainStep):
    def __init__(self):
        self.name = "test_stepDict"

    def run(self, stepDict):
        print(type(stepDict["mgearRun"].groups))
        for eachSet, setMembers in stepDict["mgearRun"].groups.items():
            print(eachSet) # a string of the name of the "group"
            print(setMembers) # the members in the ObjectSet node.
1 Like

Hi Chris,

Thanks a lot for your answer, I really appreciate the time you took to clarify everything!

The connection to the message attribute is what I was looking for. I should be able to have the robustness that I need with that method :slight_smile:

Thanks also for clarifying the “groups” dictionary!

Cheers!

1 Like