pm.cmds.file and referenceNode

237 views
Skip to first unread message

Justin Rosen

unread,
Aug 5, 2010, 8:49:35 PM8/5/10
to python_in...@googlegroups.com
Has anyone else noticed a discrepancy between the file command in mel and in python in relation to importing file references?
pm.cmds.file(referenceNode=ref.refNode, importReference=True)  #Where ref is derived from pm.listReferences()


# Traceback (most recent call last):

# File "/tmp/TOOLS_INSTALL/cent5_x86_64_py26/MayaAssets-Project/MayaAssets/library/maya/python/importComponentReference.py", line 127, in importComponentReferences

# pm.cmds.file(importReference=True,referenceNode=ref.refNode)

# TypeError: Flag 'referenceNode' must be passed a boolean argument


Is Pymel a bit stricter now?  I could of sworn this used to work. I have to resort to the following mel

pm.mel.eval("file -importReference -referenceNode " + ref.refNode)


The docs say it takes a boolean, but the mel code for importing a reference within the reference editor uses a reference node name scripts/others/referenceEditorPanel.mel


if ( $numNodes >= $numFiles ) {
        int $i = 0;
        for ( $i = 0; $i < $numNodes; $i++ ) {
            if ( size($selRefNode[$i]) > 0 ) {
                file -importReference -referenceNode $selRefNode[$i];
            }
        }
    } else {
        int $i = 0;
        for ( $i = 0; $i < $numFiles; $i++ ) {
            if ( size($selFileReal[$i]) > 0 ) {
                file -importReference $selFileReal[$i];
            }
        }
    }

Justin

John Creson

unread,
Aug 6, 2010, 3:32:06 AM8/6/10
to python_in...@googlegroups.com
I believe, in the mel, the refNode at the end is the object of the
command, not the value being passed to the flag.

You might try:

pm.cmds.file(ref.refNode, referenceNode=True, importReference=True)

> --
> http://groups.google.com/group/python_inside_maya

Ofer Koren

unread,
Aug 6, 2010, 4:09:09 AM8/6/10
to python_in...@googlegroups.com
You should be able to use the FileReference object directly:

ref.importContents()     #Where ref is derived from pm.listReferences()

- Ofer
www.mrbroken.com


Justin Rosen

unread,
Aug 8, 2010, 4:35:23 PM8/8/10
to python_in...@googlegroups.com
John,

Thats a bit embarrassing, i blame it on being a late Friday afternoon!  I'll check it out on Monday. I tried what you posted minus the referenceNode=True and was getting an error. 

Ofer,

This is an even better approach, I quickly looked over the methods available and must of passed over this one. 

Thanks guys!



- iPhone
Reply all
Reply to author
Forward
0 new messages