getting a node's typeID

108 views
Skip to first unread message

Chad Dombrova

unread,
Sep 22, 2010, 11:26:32 PM9/22/10
to python_in...@googlegroups.com
i've searched for this before without avail, but it's biting me again in a different context, so i thought i'd check:

is there a way to get the typeId of a node without having an existing instance of the node?

i would expect a static method on MFnDependencyNode, like the following:

MFnDependencyNode.getTypeId('transform')

but i can't find anything....

-chad


Jan Berger

unread,
Sep 23, 2010, 12:39:14 AM9/23/10
to python_in...@googlegroups.com

there is MFnDependencyNode::typeId()
to get it for a specific node type I guess one would need to use the create function beforehand

Chad Dombrova

unread,
Sep 23, 2010, 12:56:30 AM9/23/10
to python_in...@googlegroups.com
On Sep 22, 2010, at 9:39 PM, Jan Berger wrote:


there is MFnDependencyNode::typeId()
to get it for a specific node type I guess one would need to use the create function beforehand

yes, it's not a static/class method so the MFnDependencyNode class needs to be instantiated to use that method... meaning you need an existing node.  i've done some very nasty things using dg modifiers to create "ghosedt" nodes that do not yet exist to find out their type, the revert the dgmod, but i'd rather not have to do that.

-chad





At 08:26 PM 9/22/2010, you wrote:
i've searched for this before without avail, but it's biting me again in a different context, so i thought i'd check:

is there a way to get the typeId of a node without having an existing instance of the node?

i would expect a static method on MFnDependencyNode, like the following:

         MFnDependencyNode.getTypeId('transform')

but i can't find anything....

-chad


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

Jan Berger 
j...@janberger.de :: www.janberger.de


Jan Berger

unread,
Sep 24, 2010, 11:26:23 AM9/24/10
to python_in...@googlegroups.com

I`m not sure I have enough info to give specific advice, I presume the node may not exist that you want to get the typeId for?
If MDGModifier does not do the job how about just creating one and then use MGlobal::deleteNode() to get rid of it?
Just a thought...

isabelle boeve

unread,
Mar 14, 2024, 2:04:53 PMMar 14
to Python Programming for Autodesk Maya
for future reference to those that looked for an answer to this issue (as was I)
This is how you get a node's typeID

import maya.OpenMaya as OpenMaya

node = cmds.ls("network1")[0]
sel = OpenMaya.MSelectionList()
mobj = OpenMaya.MObject()
OpenMaya.MGlobal.getActiveSelectionList(sel)
sel.getDependNode(0, mobj)
fn = OpenMaya.MFnDependencyNode(mobj)

id = fn.typeId().id()
print(hex(id))

Reply all
Reply to author
Forward
0 new messages