CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
Thread Tools Search this Thread Display Modes
Old 09-18-2009, 07:25 PM   #1
John C.
Los Angeles, USA
Join Date: Mar 2008
Posts: 60
API: simple enough I think?

I have what seems like a trivial question.. but I'm just hacking my way to learning still.. :-)

I have an MObject attribute created on a custom locator node

in maya I want to connect another nodes output to it (say translate from a sphere)
so I do a connectAttr blah blah blah..

within the API I want to traverse to the connected node (the sphere's translate )
and be able to run a set value command on the sphere's translate directly..

how do I get from the MObject attr on my locator to an MObject attr on the connected sphere?

any help would be much appreciated. thinking I could just use api calls to listConnections mel commands if I needed to , but that seems kinda sloppy.. is there a "list connections" equiv in the API?


Old 09-18-2009, 08:16 PM   #2
Join Date: Aug 2005
Posts: 753
You'd want to use MPlug.

You need to keep clear the understanding that the MObject attribute is just a structure that defines the attribute characteristics across all nodes of that type. Eg. "All nodes of this type will have an attribute called 'myData'."

In order to look at an instance of that attribute on a specific node, you would use MPlug. Eg. To access, "myNode1.myData", you create an MPlug.

So you want to get an MObject to the instance of the node that you want to query, say myNode1, and then pass in which attribute on that node you're looking for:

MObject myNodeObj; MObject myDataAttr; // Retrieve the node you're looking for, be it by the active selection list, or name. // You should hopefully already have a static MObject on your node class to get the myDataAttr. // Create an MPlug MPlug myDataPlug( myNodeObj, myDataAttr ); // Check for connections with the plug as a destination // connectedTo( connections, asDest, asSource ) // MPlugArray connections; myDataPlug.connectedTo( connections, true, false ); // Now, parse the MPlugArray connections, and look at the plugs in that array. // Search for the one with the matching transform node and .translate attribute. // And you can do a plug.setValue() from there. //
Old 09-18-2009, 08:16 PM   #3
CGTalk Moderation
CGTalk Forum Leader
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 03:20 AM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.