Home Website Youtube GitHub

Transfer or move attribute to controls in Post

Hi,
I would like to know how can I move attributes from one control to another. I am trying to move channels from the rig “group” to world control for better accessibility. I tried using channel wrangler but get the following warning:
/ Warning: MoveChannel function can't handle an attribute of type: bool. Only supported 'double' adn 'enum' types. //

I wonder why bool isn’t supported.

Anyway, I do this too. But I just add the attributes to the world ctrl, and then connect them to the top group, and hide the top group attributes. I never thought to bother with the channel wrangler.

(A lot of boiler-plate, but this is an extract from a larger script.)

  • stepDict['mgearRun'].model is the top group.
  • attribute.addAttribute() to add the attrs.
  • If you’re doing other attributes that aren’t bools, you’d have to alter this script. I’m just looping over 3 bools.
import mgear
import mgear.shifter.custom_step as cstp
import pymel.core as pm
from mgear.core import attribute


class CustomShifterStep(cstp.customShifterMainStep):
    def run(self, stepDict):
        self.put_rig_attrs_on_world_ctrl(stepDict)

    def put_rig_attrs_on_world_ctrl(self, stepDict):
        rigAttrs = [
            'ctl_vis',
            'ctl_vis_on_playback',
            'jnt_vis',
            ]

        oModel = stepDict['mgearRun'].model
        hostControl = pm.PyNode('world_ctl')

        for attr in rigAttrs:
            attribute.addAttribute(hostControl, attr, 'bool', value=1, channelBox=True, keyable=False)
            hostControl.attr(attr).connect(oModel.attr(attr))
        attribute.lockAttribute(oModel, attributes=rigAttrs)

Thanks @chrislesage . I will try this it. In the meantime, I wrote a script with Maya commands.
Another thing I would like to ask is how can I rename the “rig” group in the post other than renaming with the usual way. I was thinking to name with a character name and put the mesh group inside it.

In the script I posted, the CustomShifterStep class exposes “stepDict”.

The top group is accessed with this. So you can rename it that way.

# get the top group. "oModel" is just my naming convention for "object".
oModel = stepDict['mgearRun'].model

# You can get the name of your character from that group too.
characterName = oModel.rig_name.get()

# Then you could rename the rig with the character name:
oModel.rename(characterName + '_RIG')

# This would rename the rig "billyGoat" to "billyGoat_RIG"
1 Like