Yeah. For sure. Perhaps you could pm me with some help on branching pymel.

-jason

On Wednesday, October 17, 2012 10:14:00 AM UTC-7, elrond79 wrote:
>
> Hey count zero - would you consider doing that work on a pymel branch? Or, 
> at least, share it with me, so I could see if it could be incorporated into 
> the main pymel HiKCharacterNode class?
>
> On Wed, Oct 17, 2012 at 10:04 AM, Count Zer0 <[email protected]<javascript:>
> > wrote:
>
>> Did you check the work Seth and I did?:
>>
>> http://www.jason-parks.com/artoftech/?p=225
>>
>> What "things" could you not do in your __init__ method. Doesn't 
>> _postCreateVirtual essentially replace the __init__ method?
>>
>> We've used this technique successfully on a couple of classes so far. 
>> Though we haven't put it through its paces too seriously. I'm about to 
>> extend the factory created nt.hikCharacterNode class to wrap all the 
>> non-documented MEL methods to the new HIK character node. After that, I 
>> should have an even more familiar knowledge of the subclassing process.
>>
>> -jason
>>
>>
>> On Saturday, October 13, 2012 1:23:09 AM UTC-7, Morgan wrote:
>>>
>>> Hey all, I've been using sort of a hacky method for extending pymel, and 
>>> I've just now been trying to get my head around subclassing with virtual 
>>> classes to upgrade my code.
>>>
>>> The way I've been doing it up to now is not inheriting directly from 
>>> pymel node classes, but rather creating a custom class and storing the 
>>> pyNode object in a member variable, and then overriding the __getattr__ 
>>> method to have access to the pyNode methods as well as my own custom 
>>> methods. It looks something like this:
>>>
>>>
>>> class MyTransform(object):
>>>
>>> def __init__(self):
>>>
>>>  self.__pyNode = pm.createNode('transform')
>>>
>>>  #any sort of custom stuff, adding attributes and assigning member 
>>> variables.
>>>
>>> def someCustomMethod(self):
>>>
>>> #do custom stuff
>>>
>>> def __getattr__(self, attr):
>>>
>>> if attr in self.__dict__: 
>>>
>>> return self.__dict__[attr]
>>>
>>> else:
>>>
>>> return getattr(self.__pyNode, attr)
>>>
>>>
>>> It's then easy to inherit from this, for example MyJoint could be 
>>> inherited from MyTransform and have access to someCustomMethod, as well as 
>>> the methods that are unique to the pymel Joint class. Of course the 
>>> downside is that it's not a real subclass, just kind of a wrapper, and it 
>>> has some limitations.
>>>
>>> Anyway, I got the virtual class stuff working from the examples, but as 
>>> I started converting my first couple classes I've run into some snags that 
>>> I wasn't sure about the best way to get around. The way 
>>> I'm approaching this conversion is I'm replacing __init__ with 
>>> _preCreateVirtual, createVirtual, and _postCreateVirtual, more or less. But 
>>> some of the things I was doing in my __init__ methods, such as setting 
>>> member variables and calling methods from this class and parent classes, 
>>> doesn't seem to be possible. And neither is adding an __init__ method, 
>>> because special methods aren't allowed in virtual classes. I'm kind of 
>>> pushing the limit of my current python knowledge with this stuff, so I'm 
>>> not really sure where to go next. My only thought was to create a wrapper 
>>> function for each class to actually call it and then assign or edit any 
>>> member variables or do anything else I can't figure out how to do during 
>>> creation. But is there some better way of dealing with this that I'm not 
>>> understanding?
>>>
>>  -- 
>> 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