import maya.cmds as cmdsimport maya.mel as mel
class Control(object): def __init__(self, name, shape, size): self.name = name self.shape = shape self.size = size
def create_me(self): if self.shape == 'box': mel.eval( 'curve -d 1 -p -0.5 0.5 0.5 -p 0.5 0.5 0.5;' ) if self.shape == 'circle': cmds.circle( radius=1 ) if self.shape == 'square': mel.eval( 'curve -d 1 -p -0.5 0 -0.5 -p 0.5 0 -0.5 -p 0.5 0 0.5 -p -0.5 0 0.5 -p -0.5 0 -0.5' )
cmds.scale( self.size, self.size, self.size ) cmds.makeIdentity( apply=True, t=0, r=0, s=1 ) cmds.rename( self.name ) cmds.select( clear=True )
legControl = Control.create_me('L_leg1_control', 'box', 2)Hi
Everything looks fine except for how you call your class
legControl = Control.create_me('L_leg1_control', 'box', 2)
create_me() is called a "method". It is bound to an instance of your class, which means you need to first make an instance of your Control.
legControl = Control('L_leg1_control', 'box', 2)
Now you have constructed an instance, with your params that were passed to your __init__()
You can call create_me() to perform that extra set up.
legControl.create_me()
Note that your create_me method does not return anything. It only performs actions on your instance.
Justin
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b6eddbbc-8d18-415e-85c7-b3d15c423c14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.