PDA

View Full Version : a Node which creates other nodes, node confusion!


jackinoob
06-27-2006, 09:50 PM
Hi all,

I am designing a custom node with API, which depending on certain factors, would need to create and maintain built-in maya nodes (i.e joint) as part of its operation. I tried doing this in the compute function of my custom node, using :

MDagModifier dagMod;

MObject prim = dagMod.createNode("joint");

This does nothing however. From my research, I've seen uses of MDGModifier and MDagModifier in the doit functions of commands. Can this be used properly within the compute of a custom node? Or is there another way to accomplish this?

please help my node confusion! Thanks.

artifish
06-27-2006, 11:21 PM
Heya,

You have to use the dag modifieres "doIt" function to actually add the nodes - from the docs:

When createNode is called, the new node is created and the MObject handle for it is returned. It should be noted that the node will not be added to the DAG until the doIt method is called.

That said - adding nodes from inside the compute function of a node seems to me like asking for trouble - a node should never know anything about the world outside of it's scope. The scope being defined by the nodes attributes...

What do you exacly want to do that requires creating objects from inside the node?

C.

Buexe
06-28-2006, 08:05 AM
Another issue to take into account is that you will run into trouble with the
undo queue, because there is no undoCompute function or similar. I would
try to write a callback that notifies me if a certain attribute changes and
then have a command or procedure to do the creation stuff.
my 2 cents

JamesPiechota
06-28-2006, 08:47 AM
You may also get some mileage from the xxxVarGroup nodes (e.g. curveVarGroup) - limited output types but they'll handle creating the nodes and undoing the creation.

CGTalk Moderation
06-28-2006, 08:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.