PDA

View Full Version : Maya API initialising Node variables


bowly
11-22-2010, 04:14 PM
Hey guys,

Learning the maya API and I have created a Node which I can plug in object translate attributes and it outputs the result I want back to those objects.

After connecting all my objects I want to get my node to update a value with the number of objects connected. Is there any way to get it to run a function which will set-up my Node so that it will compute to all of them correctly? Or am I thinking about it the wrong way? Thanks!

whisperwing
11-23-2010, 07:29 PM
Just want to make sure I understand what you want:

so you have a custom node whose output plugs connect to the translate attributes of multiple objects ? Is it an array plug or one plug for each translate attribute it connects to ?

And you want to compute the total number of objects your node is connected to ?

bowly
11-23-2010, 07:54 PM
Hey whisperwing,

It's a custom node with an array plug connected to multiple objects, I want to know if I can get my node to find the number of connections after they are connected.

Or do I just have to check during the compute function? Just seems a bit inefficient..

whisperwing
11-23-2010, 08:22 PM
One way to do it is to use Mplug::connectedTo() to get all the plugs it connected to. Then just check the size of the MplugArray returned from the function. This way could be used even if your plug is not an array plug.
But since you are using an array plug, you can use Mplug::numConnectedElements().

bowly
11-24-2010, 03:43 PM
awesome thanks bud I'll do that!

CGTalk Moderation
11-24-2010, 03:43 PM
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.