Re: [Maya-Python] Re: .MFileIO.getReferenceFileByNode - // Error: (kInvalidParameter): Invalid parameter

2018-02-19 Thread Sivanny Selvakumar
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 > 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 .
>> 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_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.


[Maya-Python] Re: .MFileIO.getReferenceFileByNode - // Error: (kInvalidParameter): Invalid parameter

2018-02-16 Thread Sivanny Selvakumar
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.
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.


Re: [Maya-Python] List referenced files

2015-08-12 Thread Sivanny Selvakumar
Hi Marcus,

Just a quick note about the fileNames attribute. It's actually obsolete and 
hasn't been used since Maya 6.0. It was only kept around for backwards 
compatibility. After Maya 6.5, reference paths are only accessible via the 
referenceQuery and the file command. Other attributes that are not used 
anymore include connectionList, setAttrList, addAttrList, deleteAttrList, 
brokenConnectionList, parentList, edits and multiParentList. 
placeHolderList is still used, though. It looks like the node docs don't 
really state this, but they totally should!

Just FYI,

Sivanny


On Wednesday, August 12, 2015 at 12:12:17 AM UTC-7, Marcus Ottosson wrote:

 What’s more, it doesn’t look like reference nodes contain their 
 unresolved filename, maybe this is resolved by the editor itself?

 # Always returns a resolved path?
 cmds.getAttr(ben02_RN.fileNames[0])



-- 
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/471b115e-6e9e-4a3b-bdf1-4ca0dc2d44b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] List referenced files

2015-08-12 Thread Sivanny Selvakumar
It's stored in internal data structures. So the only way to access/change 
it is via the referenceQuery command, the file command or MFnReference.

On Wednesday, August 12, 2015 at 9:45:22 AM UTC-7, Marcus Ottosson wrote:

 Oh, that's an interesting note, thanks for sharing Sivanny.

 So, how would one access the path from a reference node? Is the 
 information not stored in the node at all? Where is it stored?

 On 12 August 2015 at 17:27, Sivanny Selvakumar sivanny.s...@gmail.com 
 javascript: wrote:

 Hi Marcus,

 Just a quick note about the fileNames attribute. It's actually obsolete 
 and hasn't been used since Maya 6.0. It was only kept around for backwards 
 compatibility. After Maya 6.5, reference paths are only accessible via the 
 referenceQuery and the file command. Other attributes that are not used 
 anymore include connectionList, setAttrList, addAttrList, deleteAttrList, 
 brokenConnectionList, parentList, edits and multiParentList. 
 placeHolderList is still used, though. It looks like the node docs don't 
 really state this, but they totally should!

 Just FYI,

 Sivanny


 On Wednesday, August 12, 2015 at 12:12:17 AM UTC-7, Marcus Ottosson wrote:

 What’s more, it doesn’t look like reference nodes contain their 
 unresolved filename, maybe this is resolved by the editor itself?

 # Always returns a resolved path?
 cmds.getAttr(ben02_RN.fileNames[0])

 -- 
 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/471b115e-6e9e-4a3b-bdf1-4ca0dc2d44b0%40googlegroups.com
  
 https://groups.google.com/d/msgid/python_inside_maya/471b115e-6e9e-4a3b-bdf1-4ca0dc2d44b0%40googlegroups.com?utm_medium=emailutm_source=footer
 .

 For more options, visit https://groups.google.com/d/optout.




 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:


-- 
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/da78fdf6-c9c6-42dc-9950-82e1be13541d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] List referenced files

2015-08-11 Thread Sivanny Selvakumar
`file -q -list` will return all the file reference paths and string 
attributes marked as usedAsFilename. So it saves you from having to iterate 
over the nodes in the scene yourself. This is how Maya gets a list of files 
for the File  Archive Scene feature. You can also access this 
functionality from outside Maya with the `maya.exe -archive scene_file` 
flag. 

As long as your plugin nodes mark their file path attributes as 
usedAsFilename, or override the MPxNode::getFilesToArchive function, it 
should pick up the paths.


On Tuesday, August 11, 2015 at 8:59:47 AM UTC-7, Marcus Ottosson wrote:

 I’m looking for a way to list all nodes that somehow reference an external 
 file; be it references, textures, or some obscure custom node with an 
 attribute for paths.

 I was looking at the cmds.filePathEditor 
 http://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/CommandsPython/filePathEditor.html
  
 which is close.

  cmds.filePathEditor(query=True, listDirectories=)
 [list of paths]

 But it doesn’t show me which nodes are responsible for these paths, and 
 doesn’t show me the full filenames.

 Any ideas?
 ​
 -- 
 *Marcus Ottosson*
 konstr...@gmail.com javascript:


-- 
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/1ebbe8ae-aada-4a31-8e71-2eddd8f02e93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: MFnNurbsCurve closestPoint issue C++

2015-04-20 Thread sivanny . selvakumar
I ran into a very similar problem with MFnMesh:: getPointAtUV a few months ago. 

The solution in my case was to use the MDagPath constructor instead of the 
MObject one for your MFn* class. Apparently, functions that require a dag path 
won't actually return an error if you used the other constructor to build your 
MFn* object. They just fail silently.

I logged a bug for the getPointAtUV issue. If this turns out to be a similar 
thing, I think you should log it. Autodesk needs to know how painful this is 
for customers. Maya's API should either return an error, or use the first path 
to an object under the covers. In fact, pretty much anything other than failing 
silently would have been nice.

Sivanny

-- 
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/d0a81d6f-3266-4885-9e62-f2c15e74076b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.