My Current node name

55 views
Skip to first unread message

miarmy

unread,
May 1, 2018, 10:13:15 AM5/1/18
to Python Programming for Autodesk Maya
Hi.in the compute function of my nodr...i want know
What is my node name...and what is the node name which us connected to one attribute of my node.
...
def compute(self, plug, data):
#get name:

Please help!help!....python api 2.0...

Ravi Jagannadhan

unread,
May 1, 2018, 1:30:49 PM5/1/18
to python_in...@googlegroups.com
The API docs for MPxNode should list a function that'll give you this. I think it's just name(...) but double check in the docs.


--
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_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c5d30fe2-889a-41cf-b465-6b9fe76dc834%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Where we have strong emotions, we're liable to fool ourselves - Carl Sagan

miarmy

unread,
May 2, 2018, 12:49:37 AM5/2/18
to Python Programming for Autodesk Maya
Thanks...i use self.name() code in my node compute function(api 2.0) to query node name....now,how i can query node nam in c++ API comput function!?😀

Rémi Deletrain

unread,
May 2, 2018, 3:03:56 AM5/2/18
to Python Programming for Autodesk Maya
I give an exemple in Python but is a same way for c++ API

mfn_node = OpenMaya.MFnDependencyNode(self.thisMObject())

You want to get node connected to your node in input ? You try to get node name for use cmds ? it's possible to get with API.

get plug with findPlug function of MFnDependencyNode:
    mplug = mfn_node.findPlug(MObject_Attribute)

And use connectedTo of MPlug
    mplug.connectedTo(yourPlugArray, True, False) # for get input
    mplug.connectedTo(yourPlugArray, False, True) # for get output
    mplug.connectedTo(yourPlugArray, True, True) # for get both

You must prefere to get this data in connectionMade function of your MPxNode rather than the compute.
Reply all
Reply to author
Forward
0 new messages