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 
reference*d* node -- the sphere.

You can query the reference node for a reference*d* 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

On Thursday, February 15, 2018 at 2:33:11 AM UTC-8, Nicolas Chaverou wrote:
>
> 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? 
> ---
> [image: Nicolas Chaverou - Golaem Crowd Product Manager - Golaem SA]
>  
> +33 (0)2 99 27 21 44
> http://www.golaem.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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/844f9ea6-9da9-4c6d-82d7-e766190e3f57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to