.MFileIO.getReferenceFileByNode - // Error: (kInvalidParameter): Invalid parameter

256 views
Skip to first unread message

Nicolas Chaverou

unread,
Feb 15, 2018, 5:33:11 AM2/15/18
to python_in...@googlegroups.com
Hey there,

Was trying to fetch information about the file a node has been referenced from but I can't get OpenMaya.MFileIO.getReferenceFileByNode to work properly.

I'm running the following piece of code:

import maya.OpenMaya

selectionList = maya.OpenMaya.MSelectionList()
selectionList.add( 'types_ToReference:pSphere1' )
node = maya.OpenMaya.MObject()
selectionList.getDependNode( 0, node )

file = maya.OpenMaya.MFileIO.getReferenceFileByNode( node )


# RuntimeError: (kInvalidParameter): Object does not exist //


Anything I missed?

Nicolas Chaverou

unread,
Feb 15, 2018, 5:36:55 AM2/15/18
to python_in...@googlegroups.com
Oops sorry, the error I'm getting is:

// Error: (kInvalidParameter): Invalid parameter


Justin Israel

unread,
Feb 15, 2018, 4:04:17 PM2/15/18
to python_in...@googlegroups.com
On Thu, Feb 15, 2018 at 11:36 PM Nicolas Chaverou <nicolas....@golaem.com> wrote:
Oops sorry, the error I'm getting is:

// Error: (kInvalidParameter): Invalid parameter



Seems like you are using it the way the API describes.
Is it possible to use cmds.referenceQuery(dagPath, filename=True)  ?
 
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFS5DCa_xE%2BkX2QpdxwAE7VjT1eBJvZDC6YmjMruRwyjDy-LHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Nicolas Chaverou

unread,
Feb 16, 2018, 4:20:36 AM2/16/18
to python_in...@googlegroups.com
Thing is I need this code to work within the C++ API
As I couldn't make it work, I took a look at the Python side but it returns the same error

I thought that if I was able to make it work in Python, It'll help me figure out what's wrong on the C++ side :/

Thanks for looking at it anyway
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2LYuiKGj0mTNsBKKu-x4zp15hj-hQiR2bRxejFXbsXuA%40mail.gmail.com.

Marcus Ottosson

unread,
Feb 16, 2018, 5:14:26 AM2/16/18
to python_in...@googlegroups.com
I get that error when, unsurprisingly, the object does not exist.

Do you have a reproducible, including the creation of that sphere?

Nicolas Chaverou

unread,
Feb 16, 2018, 9:33:38 AM2/16/18
to python_in...@googlegroups.com
Hey Marcus,

Which error is that ?
In my first email, I pasted the wrong error line.

The one I'm actually getting is
// Error: (kInvalidParameter): Invalid parameter

Regarding the scene : create a sphere poly, save it
Reference that scene using the Create Reference... menu in Maya
Run the code (change the namespace if required)

On Fri, Feb 16, 2018 at 11:12 AM, Marcus Ottosson <konstr...@gmail.com> wrote:
I get that error when, unsurprisingly, the object does not exist.

Do you have a reproducible, including the creation of that sphere?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Nicolas Chaverou

unread,
Feb 16, 2018, 1:11:42 PM2/16/18
to python_in...@googlegroups.com
Hey,

Weirdly the following commands which take MObject don't work neither

maya.OpenMaya.MFileIO.loadReferenceByNode(node)

// Error: line 1: Please specify a reference node or referenced file to unload. //


maya.OpenMaya.MFileIO.unloadReferenceByNode(node)

// Error: line 1: Please specify a reference node or referenced file to unload. //


On Fri, Feb 16, 2018 at 3:33 PM, Nicolas Chaverou <nicolas....@golaem.com> wrote:
Hey Marcus,

Which error is that ?
In my first email, I pasted the wrong error line.

The one I'm actually getting is
// Error: (kInvalidParameter): Invalid parameter

Regarding the scene : create a sphere poly, save it
Reference that scene using the Create Reference... menu in Maya
Run the code (change the namespace if required)

On Fri, Feb 16, 2018 at 11:12 AM, Marcus Ottosson <konstr...@gmail.com> wrote:
I get that error when, unsurprisingly, the object does not exist.

Do you have a reproducible, including the creation of that sphere?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.

Sivanny Selvakumar

unread,
Feb 16, 2018, 2:28:55 PM2/16/18
to Python Programming for Autodesk Maya
Most referencing commands/functions require you to pass in the reference node (i.e. node type is "reference"). It looks like you are trying to use a referenced node -- the sphere.

You can query the reference node for a referenced object with `referenceQuery -referenceNode ref:pSphere1`. This should give you something like sphereRN. You can then get the MObject for sphereRN, pass it to getReferenceFileByNode and it should work.

I don't think this particular referenceQuery functionality is exposed in C++. It really should be. It's annoying that MFnDependencyNode has isFromReferencedFile, but doesn't give you a way to query which reference it's a part of.

Sivanny

Nicolas Chaverou

unread,
Feb 19, 2018, 9:10:44 AM2/19/18
to python_in...@googlegroups.com
Hey Sivanny,

You're correct indeed...
So no way, on the API side to easily fetch the reference file of a referenced node... Dammit...
I'll have to figure something else, it's annoying indeed.

Best,

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/844f9ea6-9da9-4c6d-82d7-e766190e3f57%40googlegroups.com.

Sivanny Selvakumar

unread,
Feb 19, 2018, 1:01:28 PM2/19/18
to Python Programming for Autodesk Maya
The only thing you can do is use MGlobal::executeCommand to run the referenceQuery command in C++.
I would log a defect with Autodesk about this, since it's such a big hole in the API.
Reply all
Reply to author
Forward
0 new messages