PDA

View Full Version : API- Trouble Accessing Transform Nodes


Spireite
02-20-2007, 03:06 PM
Hi,

Ok, so when i create a locaotr in the api obviously it creates the locatorShapeNode and has transform node as a parent (i think).

MFnDagNode daLocator;

daLocator.create("CustomLocator");

this works and create both the custom locator node and the transform node, but if i do

daLocator.name()

it returns transform1, the dagNode function set is pointing to the transform node instead of the locator node.

How do i gain access to the actual locator node?? I think its something to do with hasChildren/hasParent but ive never used this before.

Any suggestions welcomed

Spireite

Robert Bateman
02-21-2007, 02:19 PM
MFnDagNode daTransform;
MFnDagNode daLocator;

daTransform.create("CustomLocator");
daLocator.setObject(daTransform.child(0));


you can also use the childCount(), parent() and parentCount() funcs to access all of the parenting info in Maya. It's kinda annoying, but whenever you create a new shape node (locator etc) Maya always generates a new parent transform for it and returns that from the call to create(). This never used to be the case (pre Maya 5.0 as i recall). It's exceptionally annoying when using classes derived from MFnDagNode (ie, MFnMesh) since it attempts to bind the function set to the transform - which in the case of MFnMesh always ends up as an invalid operation. FYI, the returned MObject is always for the parent transform. So, if you ever use MFnMesh etc, then the following is normally what you end up doing...


MFnTransform daTransform;
MFnMesh daMesh;

MObject oTransform = daMesh.create( /* some args here */ );
daTransform.setObject(oTransform );
daMesh.setObject( daTransform.child(0) );

CGTalk Moderation
02-21-2007, 02:19 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.