Judah: sorry, I still didn't test it out... just made a quick run on the
docs to check that script support thingy. Anyone tried clicking the obsolete
node's "see the other method" link to get into the same method? Maya docs
2009/2010 have some kind of error maybe? Anyhow, I'll give it a try using
the callback later!

Dado: this doesn't work as my node doesn't have a transform. Recursively, I
tried getting the node's name through a selection list:

#this code goes into postConstructor
selList = OpenMaya.MSelectionList()
        selList.add(self.thisMObject())
        lista = []
        selList.getSelectionStrings(lista)
print 'Node name =', lista[0]

...with no success, still doesn't print out the node's name! :(

Thanks for all your help guys!



On Mon, Nov 30, 2009 at 4:48 PM, Dado Feigenblatt <[email protected]> wrote:

>  I needed to use postConstructor once and this was the only way I got it to
> work.
> The key part is to call postConstructor() on the base class.
>
> dado
>
> def postConstructor(self):
>         *OpenMayaMPx**.MPxTransform.postConstructor(self)*
>         thisNode = self.thisMObject()
>         dagFn = OpenMaya.MFnDagNode(thisNode)
>
>
>
> Richard Kazuo wrote:
>
> Thanks for the help Chad.
>
> Just to clarify, the docs also say this callback is obsolete and to use
> another method that when I click it, it takes me to the same deprecated one
> - this also happens in addNodeDirtyCallback. What should we use instead?
>
> Richard
>
>
>
> On Sat, Nov 28, 2009 at 7:38 PM, Chad Vernon <[email protected]> wrote:
>
>> You could create a flag to only get it once in the compute method.  Or you
>> could create a callback MNodeMessage::addNameChangedCallback which gets
>> called whenever the name changes.  Unfortunately, the docs say it's not
>> available in Python.
>>
>> -Chad
>>
>>   On Wed, Nov 25, 2009 at 6:52 AM, Richard Kazuo <[email protected]>wrote:
>>
>>>  Hi all, I was wondering how I could get access to a created node's name
>>> in Maya's DG.
>>>
>>> I tried getting it using the *self.name()* method inside the *__init__*and 
>>> that crashes Maya. I checked the MPxNode documentation and it says the
>>> node is not yet created in the constructor, so it makes sense. The docs say
>>> I should use the *postConstructor *method, but I tried it and it doesn't
>>> give me the name - I can only access it on the *compute *method.
>>>
>>> This is what I used to test:
>>>
>>> class testNode(OpenMayaMPx.MPxNode):
>>>     def __init__(self):
>>>         #print 'constructor>', self.name()  #this crashes Maya
>>>         OpenMayaMPx.MPxNode.__init__(self)
>>>
>>>     def postConstructor(self):
>>>         print 'post constructor>', self.name()
>>>
>>>     def compute(self,plug,dataBlock):
>>>         print 'compute>', self.name()
>>>
>>>
>>>  Maya only prints out the node name in the compute section.
>>> Any thoughts on how I could get the node's name only once (outside the
>>> compute)? I can access *self.typeName()* though. Maybe I'm messing with
>>> something I shouldn't?
>>>
>>> Thanks in advance,
>>> Richard
>>>
>>>
>>> --
>>> http://groups.google.com/group/python_inside_maya
>>>
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>>
>
> --
> http://groups.google.com/group/python_inside_maya
>
>
>
>  --
> http://groups.google.com/group/python_inside_maya
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to