PDA

View Full Version : Maya c++ Plugin error: (kInvalidParameter): Object is incompatible with this method


tommix
08-04-2010, 03:02 PM
Hi,
I am writing a plugin for the calculus of the autorotation of a wheel based on differential calculus instead the classical way.
I have created a custom locator named rollLocator.

It works fine if I call the MEL command: createNode rollLocator

But if I try to create the node via C++ using the MDGModifier class or the MDagModifier, in this way:

MObject rollLocatorObj = dagMod.createNode("rollLocator", MObject::kNullObj, &status);

OR

MObject rollLocatorObj = dagMod.createNode(RollLocator::typeId, MObject::kNullObj, &status);

I get the following runtime error:

Plugin error: (kInvalidParameter): Object is incompatible with this method

Any ideas how to solve the problem or reference this new locator alternatively in C++?

Thank you

Creepfree
08-04-2010, 04:59 PM
Hey
Hm,what version are you working with?I mean,i'm using 2008 and there is no createNode implementaion (in both MDGModifier and MDagModifier classes) that takes a MObject enum member..."kNullObject" doesn't sound right if you're building dg node^^
Anyway,when building dg node i used to call MDgModifier createNode("nodeName") method and it worked just fine so far.If you can't replace this enum member...well if you can share a code snippet it'll be much easier to see what's the problem..

tommix
08-04-2010, 05:39 PM
Hi Crepfree, thanks very much for your reply.
I am using Maya 2009.
This is the crimed piece of code:


MObject rollLocatorObj;
//Create a rollLocator locator for each kTransform node
rollLocatorObj = dgMod.createNode("rollLocator", &status);
if (status != MS::kSuccess){
MGlobal::displayError(status.errorString());
return status;
}


The MDagModifier has a member 'createNode()' that takes as parameters a MObject representing the parent node and this is set by default as null.

Sounds strange that dgMod.createNode("rollLocator") doesn't work giving that runtime error, meanwhile creating the node via the MEL command: createNode rollLocator works fine.

Moreover the dgMod.createNode(..) works fine for the creation of a new node defined for the plugin. The problem seems to exist just for locator nodes..

Any ideas to get a reference to a new rollLocator locator (or a standard locator, that's almost the same)?

Thanks

tommix
08-04-2010, 06:00 PM
I tryed this way:



MObject rollLocatorObj;
//Create a rollLocator locator for each kTransform node
rollLocatorObj = dgMod.createNode("RollLocator", &status);
if (status != MS::kSuccess){
MGlobal::displayError(status.errorString());
return status;
}


In this case I get this error:

// Error: (kFailure): Unexpected Internal Failure

Creepfree
08-04-2010, 07:22 PM
Wait a second,i'm a little confused^^,are you developing a DG or DAG node (MPxNode herit) or a Locator "node"(MPxLocator herit)?

Edit:Sorry,haven't noticed "just for locator nodes.."^^.In this case,why do you need create it via API call?I mean,locators are normally created using createNode command...you just create them and use them as constraints,goals,or whatever you need.But maybe you want to develop dg node instead?So that if you have an object,you create a node connected with this object and controlling one of it's attributes through another...
By the way,dunno if you have David Gould's Maya's programming book (great one),but there is an example regarding custom locator's development.And for instancing this locator,createNode command is used there as well,so i think it's the only right approach.

tommix
08-04-2010, 10:49 PM
Hi,
in my plugin I have created a MPxNode subclass and a MPxLocator subclass (to have a custom locator attached to the MPxNode).
The MPxNode works fine with createNode method.. the problem is with the MPxLocator.
I can instantiate it via MEL command and not via C++ using createNode().

I have that book and Mr. Gould shows also a way to create the auto rolling node but it's not based on differential calculus and has some limitations.. that's why I am implementing my own version, that works fine, except for having this custom locator that shows some guides to help the user setting up the node correctly.

So you say that to instantiate a MPxNode subclass and a MPxLocator subclass I can't use both classes?

Thanks for your patience.

tommix
08-05-2010, 01:46 PM
Ok..
I'll try to formulate the question in a different way..

How to create a simple locator via C++?

dgMod.createNode("locator") seems to fail for me

tommix
08-05-2010, 02:00 PM
Problem solved.
The right way to create the custom locator is via MDAGModifier.. the problem was that I forgot to call the doIt() command. ;)

Creepfree
08-05-2010, 02:05 PM
Nice,good luck with it^^

CGTalk Moderation
08-05-2010, 02:05 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.