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.

On Monday, February 19, 2018 at 6:10:44 AM UTC-8, Nicolas Chaverou wrote:
>
> 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,
>
> ---
> [image: Nicolas Chaverou - Golaem Crowd Product Manager - Golaem SA]
>  
> +33 (0)2 99 27 21 44
> http://www.golaem.com
>
> On Fri, Feb 16, 2018 at 8:28 PM, Sivanny Selvakumar <
> sivanny.s...@gmail.com <javascript:>> wrote:
>
>> 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 python_inside_maya+unsubscr...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/844f9ea6-9da9-4c6d-82d7-e766190e3f57%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/844f9ea6-9da9-4c6d-82d7-e766190e3f57%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/ce18311e-516e-4650-a02e-07c0e68d22ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to