hi chad,
i try the customClasses technique but i have a problem i can test if a
attribute exist in the callback fonction
but not get his value.

code :
from pymel import *

class LegJoint(Joint):
    """ this is an example of how to create your own subdivisions of
existing nodes"""

    def kick(self):
        print "kicking"

class JawJoint(Joint):
    """ this is an example of how to create your own subdivisions of
existing nodes"""

    def munch(self):
        print "munching"

def legJointCallback( fn, name ):
    """if the desired attribute exists, then we're a LegJoint!"""
    try:
        print "testing if this is a leg joint"
        # this function fails if the attribute does not exist, so we
have to try/except it.
        return fn.hasAttribute( 'jointType_leg' )
    except: pass
    return False

def jawJointCallback( fn, name ):
    """if the desired attribute exists, then we're a LegJoint!"""
    try:
        # this function fails if the attribute does not exist, so we
have to try/except it.
        print "testing if this is a jaw joint"
        return fn.jointType_jaw.get() == 'yes'
    except: pass
    return False

LegJoint.registerVirtualSubClass( legJointCallback,
nameRequired=False )
JawJoint.registerVirtualSubClass( jawJointCallback,
nameRequired=False )


def testJoint():
    joint()
    joint()
    j1 = joint()
    j2 = joint()
    j1.addAttr( 'jointType_leg' )
    j2.addAttr( 'jointType_jaw',dt='string' )
    j2.jointType_jaw.set('yes')

    # now list the joints and see which ones are our special joints
    res = ls(type='joint')
    for x in res:
        if isinstance(x, LegJoint ):
            x.kick()
        elif isinstance(x, JawJoint ):
            x.munch()

sorry for my english and thank you for the fantastic work you are
doing.
colas
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to