Get all attribute of a class Node in c++ ?


#1

Hello!

I would like to know if there is a way to know all attribute of a node before creating/instantiating it ? basically, provide the name of the node I wish to create, but only get all the name of static attribute that this node will have.

What I could do is probably create the node, get the info, and delete it right away, but it pretty messy, is there a more clean way of doing it ?

Thanks!


#2

most probably not. Even though node definition (e.g. static initialize() method) happens before the instance is created, don’t think you’ll have access to that internal Maya’s database. You’ll need the MObject of node’s instance to do any kind of inspection via MFnDependencyNode.

What is it that you’re trying to build? A pre-built database of node attributes is not really helpful as you might have dynamically added attributes, very common for rig controls, for example.


#3

Hey,

I had doubt it was not possible, I’m in fact, making a advanced kind of rig generator, and I wanted to make my own database of attribute in order to lets the user specify in advance the kind of connection to do between node, if anything, my tool will be in charge of making the dynamic attribute, but will not affect already made node.

Guess I’ll have to create few instance when the plugin initialize!

Thanks for the answer.


#4

If you dont mind to fire some MEL commands from inside the api you could use “listAttr” to get a list of attributes of certain types. And “attributeQuery” gives some additional attribute info, might be worth a look.


#5

Thanks zaskar,

Unfortunately, this command still require that we provide an instantiated node in the viewport.

I guess I have no choice but to instantiate them when the plugin get initialized.


#6

Yep but if you just create it outside the undo chain and delete it after attribute queries this shouldnt be a problem. Wont win the beauty price but should work. ^^