Right, all the pymel methods are available, but in that example, if I add a 
method to CustomJointBase called customMethod and then try to call that 
within _postCreateVirtual like so:

newNode.customMethod()

I get an error because I newNode isn't an instance of my new virtual class:
# AttributeError: nt.Joint(u'leftLeg') has no attribute or method named 
'customMethod' # 

I can call it just fine once the class has been instanced in another 
function or script, just not within the node creation methods of the class 
itself. Is that right?

On Saturday, October 20, 2012 8:19:33 AM UTC+13, elrond79 wrote:
>
> Nope, it's an instance of the class, and you can use it exactly as you 
> would self.  Check the example file at:
>
> https://github.com/LumaPictures/pymel/blob/master/examples/customClasses.py
>
> In it's _postCreateVirtual, it adds an attribute, and calls it's .attr 
> method...
>
> - Paul
>
> On Fri, Oct 19, 2012 at 12:13 PM, Morgan <[email protected]<javascript:>
> > wrote:
>
>> But that new node is different from self because it's just a node, not an 
>> instance of the class, so although you can act on the node directly, you 
>> can't call any of the custom methods or set member variables, I don't 
>> think....
>>
>>
>> On Saturday, October 20, 2012 7:33:39 AM UTC+13, elrond79 wrote:
>>>
>>> Morgan - though _postCreateVirtual is indeed a classmethod, when it is 
>>> called by pymel's mechanics, it is always passed in the "newNode" as the 
>>> first argument (after the classmethod-automatically-**created 'cls' 
>>> arg, of course).  So you can use this arg just as you would "self" in a 
>>> "normal" instance method.
>>>
>>> - Paul
>>>
>>  -- 
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings: 
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to