bIt might be useful to take a look at mt Red9 pack. In there is a module called Red9_Meta which is aimed at OOP oriented system type of coding, in fact there's a subclass called metaRig which at the moment is just a class designed to bounce round rigs. However, the idea of all of this is that it gives you some really nice hooks to subclass and do your own setups. I've tried to add a ton of MetaData help on the blog about the concepts involved.
For procedural rigs etc the idea would be something like Alex mentioned. I'd start with a baseClass that's just an empty system but has all the hooks and core functions that any rig subsystem would need, things like anchor points, system type, switches etc. Then I'd subclass that for all your rig parts, treating arms as a system, legs as a system, hands/finger/head etc all as subsystems. This way any generic calls you add to the baseClass you automatically get. If you subclass the baseclass from meta you also get the advantage of a factory class and all the meta wrapping that I've been adding, and there's some very useful attr handling in there. More over when you run the calls in meta it will return you back the correct class from the objects involved, you run getConnectedMetaData() on a hand controller and it doesn't just give you back the controller, it gives you back your ArmSubsystem as the python class it came from already instantiated.....makes coding so much easy as all those specific cases you always add are wrapped and managed for you ;) Mark red9: http://red9-consultancy.blogspot.co.uk/search/label/Metadata<http://red9-consultancy.blogspot.co.uk/> On 13 March 2013 09:36, Simen Chris <[email protected]> wrote: > Thanks a lot Sasha, that's really helpful! :) > > I have a quick question about a utility module, I'm not sure how to build > the different methods in a flexible way. > Here's an example (pseudo-code-ish): > > #Method for locking/unlocking attributes > def lockAttr(objects, attributes, state): > for obj in objects: > for attr in attributes: > if state == "lock": > cmds.setAttr( obj + '.' + attr, lock=True, keyable=False ) > if state == "unlock": > cmds.setAttr( obj + '.' + attr, lock=False, keyable=True ) > > #Try to call the method > lockAttr(['pSphere1','pSphere2'], ['translateX', 'translateZ', 'lock') > > This is what I want (kinda), a flexible way so that I can run the command > in one line, and have multiple objects as inputs, and define wether to lock > or unlock it. I was wondering if you could give an example on how you would > go about doing this in a method? > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- ------------------------------------- Mark Jackson Technical Animation Director http://markj3d.blogspot.com/ -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
