View Full Version : Passing Objects Into A Custom Command In The API
Spireite 01-04-2007, 03:17 PM Hi,
I am trying to develop a custom command in the API which i want to affect an object in Maya, i have created custom commands before and have had no problem adding flags to the commands, but ive never passed in an object before.
eg.
customCommand(pSphere1);
I want my command to take an argument of an existing object in Maya so i can then access its DAG paths.
Another problem is that i cant use the selection list as the command is for use in a simulation
Any Suggestions??
Thnx
|
|
Robert Bateman
01-04-2007, 11:26 PM
use MSyntax::setObjectType(kSelectionList) and it should be pretty apparent. Just because the args it gives you from MArgDataBase::getObjects() comes in the form of a selection list, doesn't mean that selection list has been passed to MGlobal::setActiveSelectionList().
Spireite
01-04-2007, 11:45 PM
Thanks for the reply but im still having problems and its driving me nuts!!
So far i have this code and descriptions as to what i THINK should happen within my plugin, which compiles nicely and loads into maya no problems
MSyntax RoadConnectCmd::newSyntax()
{
syntax.setObjectType(MSyntax::kSelectionList);
return syntax;
}
MStatus RoadConnectCmd::doIt ( const MArgList &args)
{
MStatus stat;
MDagPath dagPath;
MArgDatabase argData; //Creates An Argument Database To Store All The Objects Passed Through The Command
MSelectionList passedObject; //Creates A Maya Selection List And Populates It With The Object Passed From The Command
argData.getObjects(passedObject); //Gets The Objects from the argument database and populates the MSelectionList passedObjects
passedObject.getDagPath(0, dagPath); //Gets The DagPath of The Objects Passed Into The Command
return redoIt();
}
however when i try and run the command RoadConnect() whilst trying to pass an object into the procedure
eg.
Road Connect(pSphere1);
maya has a fit and i get the error message
// Error: RoadConnect(pSphere1); //
// Error: Invalid use of Maya object "pSphere1". //
Ive only been coding for about 6 months so if you or anyone could elaborate further it would be much appreciated.
Spireite
01-04-2007, 11:50 PM
oops duplicated message
Robert Bateman
01-05-2007, 04:07 AM
tried calling the mel command like so ?
RoadConnect "pSphere1" ;
Also have a closer look at the way you are using MSyntax & MArgDataBase. currently it's not parsing the args at all. Check out the Function7 example here :
http://www.robthebloke.org/mayaapi.html#8
Spireite
01-05-2007, 03:33 PM
Thanks a lot for the link and the help ive finally managed to get thisngs moving again, should be able to get on with the rest of the development now.
Thanks again
Spireite
CGTalk Moderation
01-05-2007, 03:33 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.