maya-usd icon indicating copy to clipboard operation
maya-usd copied to clipboard

mayaUsdProxyShape.filePath missing when querying external file dependencies

Open ColinKennedy opened this issue 2 years ago • 1 comments

Describe the bug The mayaUsdProxyShape has an attribute to refer to a file on-disk however that path is not attribute / attribute value is not discoverable via the Maya API, that I can see right now.

Steps to reproduce Run this script

import tempfile

from maya import cmds
from pxr import Sdf

def _get_all_external_files():
    output = set()
    
    directories = cmds.filePathEditor(query=True, listDirectories="", unresolved=True) or []
    
    for directory in directories:
        output.update(
            cmds.filePathEditor(
                query=True,
                listFiles=directory,
                withAttribute=False,
                unresolved=True,
            ) or []
        )

    return output

_, path = tempfile.mkstemp(suffix="_some_path.usda")
layer = Sdf.Layer.CreateNew(path)
Sdf.CreatePrimInLayer(layer, "/root")
layer.Save()
node = cmds.createNode("mayaUsdProxyShape")
cmds.setAttr("{node}.filePath".format(node=node), layer.realPath, type="string")
print("external files", layer.realPath in _get_all_external_files())
print("file path attributes", cmds.listAttr(node, usedAsFilename=True))
print("known, used files in the maya scene", layer.realPath in cmds.file(list=True, q=True))

Note that:

  • the filePath attribute's text from the created mayaUsdProxyShape is not listed out of _get_all_external_files()
  • cmds.listAttr(node, usedAsFilename=True) returns [u'templatePath', u'iconName'], which is missing the expected u'filePath'
  • cmds.file(list=True, q=True) does not detect the Sdf Layer path (this may be intended behavior, just figured I'd point it out in case. The other two points are bugs though)

Expected behavior

  • _get_all_external_files() should include the created tempfile.mkstemp path in its returned set
  • cmds.listAttr(node, usedAsFilename=True) should contain u'filePath' as a returned value
  • (maybe) cmds.file(list=True, q=True) would contain the same tempfile.mkstemp path as _get_all_external_files()

Specs (if applicable):

  • OS & version: CentOS Linux release 7.9.2009 (Core)
  • Compiler & version: 9.3.1
  • Maya version: 2022.4.1
  • Maya USD commit SHA: 0fbed565b9fae9685f0a6553f3f30135b512463b (v0.12.0)
  • Pixar USD commit SHA: 7a5f8c4311fed3ef2271d5e4b51025fb0f513730 (v21.08)

Additional context Since we're a few versions behind maya-usd's latest release, if you are aware of any changes to the Maya attributes in the plug-in, we can try upgrading to the latest maya-usd if you think that will fix the issue.

ColinKennedy avatar Sep 15 '22 00:09 ColinKennedy

I believe this is directly related to https://github.com/Autodesk/maya-usd/issues/1337

swillisart avatar Sep 28 '22 01:09 swillisart