Adding attributes to a custom node on the fly

Hello everyone,

I am working on making a node and i would like to be able to have a button in the attribute editor that will add extra attributes to my node.

I am creting the node in Python and using MEL for the AE<node name>Template
I am able to create a simple class method inside my plug-in module that prints a message when the button is pressed.

I have been trying to add the custom attributes using the OpenMaya.MFnDependencyNode() class , and it’s .addAttrribute()method.

ex.
nodeFn = OpenMaya.MFnDependencyNode()
nodeFn.addAttribute(<nodename.attreibuteName>, OpenMaya.MFnDependencyNode.kLocalDynamicAttr)

It looks like the constructor for OpenMaya.MFnDependencyNode() needs a node object to operate on. I am having a lot of trouble linking my custom node to this class and its associated methods.
I have tried many things to no avail.

What i want to happen is that whenever someone selects one of my node they can add attributes to that particular node usiong the buttonm in my custom Attribute Editor UI

Any ideas?

When you say ‘creating the node in python’ do you mean it’s a custom node? In that case just add the attributes to the node creation routine - making them optional only complicates your code paths down the road since you’ll need to constantly check for their existence.

If you’re adding attribs dynamically from an AE template, you may find it easier to just call addAttr from mel in the template itself.

Hey Theodux,
Yes the node is a custom node.
Adding attributes via MEL, i cant believe how utterly complex i was trying to make this… Thank you a million for letting me borrow your brain. Mine seeme to be missing the obvious these days.
Much appreciated for the help,

Cheers,
Paul