Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / SDK / getReferenceFileByNode() -> MStatus::kInvalidParameter
  RSS 2.0 ATOM  

getReferenceFileByNode() -> MStatus::kInvalidParameter
Rate this thread
 
45024
 
Permlink of this thread  
avatar
  • Total Posts: 4
  • Joined: 19 February 2010 03:59 AM

I’m having some problems with MFileIO::getReferenceFileByNode(MObject& referenceNode, MStatus *returnStatus) whereby passed parameter ‘returnStatus’ is being set to MStatus::kInvalidParameter.

I presume this is supposed to happen when ‘referenceNode’ is not actually from a referenced file however I’m calling MFnDependencyNode::isFromReferencedFile() on the same node and it is returning true.

Here is an excerpt:

MDagPath dagPath;
if (
itDag.getPath(dagPath) != MStatus::kSuccess)
    return (
false);

MFnMesh mesh(dagPath, &status);
if (
status != MStatus::kSuccess)
    return (
false);

if (
mesh.isFromReferencedFile(&status) && status == MStatus::kSuccess)
{
    MObject node 
mesh.object(&status);
    if (
status != MStatus::kSuccess)
        return (
false);

    
MString filename MFileIO::getReferenceFileByNode(node, &status);
    if (
status != MStatus::kSuccess)
        return (
false); // <--- Reaching here.
}

I tried the following just for testing purposes and it worked as expected. i.e. The filename expected above was found.

MStringArray referencedFilenames;
MFileIO::getReferences(referencedFilenames);

for (
int i 0referencedFilenames.length(); i++)
{
    
const char *referencedFilename referencedFilenames[i].asChar();
}

Is there some circumstance whereby mesh.isFromReferencedFile() would return true and MFileIO::getReferenceFileByNode() not work. Do I have to do something first to make MFileIO::getReferenceFileByNode() work?

Any help would be very much appreciated.
Thanks



Replies: 0
avatar

For future reference to anyone experiencing the same problem. It looks as though there is a bug in the Maya API or at least a documentation error.

The workaround is to call the equivalent MEL command as follows:

char *command = new char[26 strlen(mesh.name().asChar())];
sprintf(command"%s %s""referenceQuery -filename"mesh.name().asChar());

MCommandResult result;
MGlobal::executeCommand(commandresult);
 
delete [] command;

MString referenceFilename result.stringResult(&status);
if (
status != MStatus::kSuccess)
{
    error
("Failed to get filename of referenced mesh");
    return (
false);
}


Replies: 0