How to select all CTRLs of a character problem

Hi guys,
i resort to your wisdom in Maya.

I need to bake the animation of a lot of characters and the first step for this is selecting all the controls. Ideally this wouldn’t be a problem if the names of the controls were all following the same scheme for example ending in “_CTRL”.
But i cannot rely on that.

Animators have pickers with a SELECT ALL button but it has all the control names hardcoded. That is not an option, there may be like 400 hundred controls per character in average.

We have thought of another two ideas:

  • start using character sets for every character and through python select the character sets. The inherent problem is that we would need to republish each character (we are working with shotgun).
  • start using sets and import each character set for every scene, but this has the disadvantage of slowing the animators workflow.

I’m sure we haven’t come with all possible ideas so that’s why i ask you guys, i’m sure you have faced the same problem at anytime in your work experience.

Thanks

I’m sure there’s several different solutions here, but one way to solve this would be to add metadata to the controllers. So for each control, just add a hidden attribute, that way you can easily search your scene for items with that specific attribute :slight_smile:

I second the metadata idea. Ideally, you would have a consistent naming convention and could have just done cmds.select(cmds.ls("*_ctrl")) but making sure all the controls have an attr is a good second method.
You’d loop over every nurbsCurve (or whatever object type your controls are) and see if it has that attr and add it to your selection list.
However it’ll be much slower so for future productions I’d recommend trying to consolidate on a naming convention to avoid headaches

Attributes yes, names no, sets maybe.

Attribs are perfect for permanent status information (“i am an IK control for the right hand”)
Names are useless, they break all the time
Sets are good for temporary or overlapping groupings: an IK is always an IK, but it might be in the ‘constrained’ or ‘unconstrained’ set depending on lots of circumstances. Sets are nice if human judgement is involved.

Theodox tipped me to

list(set(cmds.ls('*.MyControlAttr', o=True)))

Fast and a one liner :slight_smile:

You don’t have to select the controllers you only have to get the animation curves and bake those input channels so the following will suffice


keys = cmds.ls( type='animCurve' )
for key in keys:
    cmds.bakeResults(key)

bakeResults has a few switches for resolution and range… so you might wanna play around with that too…

[QUOTE=TheMaxx;28375]Theodox tipped me to

list(set(cmds.ls('*.MyControlAttr', o=True)))

Fast and a one liner :)[/QUOTE]

Ooh that is nice. I should try that more.

@Jamie: That should work in most cases, but it won’t work on constrained controllers for example. Also, you don’t really have much control, it will bake your entire scene unless you’re doing some filtering in your code - which quickly could be pretty painful to deal with :wink:

Yeah ok… if life was only that simple… hah… yeah I suppose you would best to target the skeleton only and bake the animation to that before export…

cmds.bakeResults(cmds.ls(sl=True), hi='below', t=(1,45), dic=True, sac=True, sm=True)

anyhow… my two cents…