Autodesk / maya-usd

A common USD (Universal Scene Description) plugin for Autodesk Maya
765 stars 201 forks source link

[EMSUSD-1276] Relative paths are not retained in mayaUsdProxyShape.filePath attributes #3751

Open jufrantz opened 5 months ago

jufrantz commented 5 months ago

Describe the bug

Since maya-usd v0.27, when creating a mayaUsdProxyShape given a relative path to an existing usd file, the filePath attribute's value now encodes the current absolute path of the file, the current working directory is baked in the maya scene file.

Prior to v0.27, the relative path remained as such and was resolved later during the proxyShape's compute. Internally, the USD resolver had the capability to resolve it in the working directory (or in other search paths).

This new behaviour is problematic for us as we need to resolve usd files from maya scenes dynamically - as with USD default resolver - for our asset management needs.

Steps to reproduce

from pxr import Sdf
from maya import cmds
  1. Create an usd file in current working dir
    layer = Sdf.Layer.CreateNew("someUsdFileInWorkingDir.usda")
    layer.ImportFromString('#usda 1.0\ndef Sphere "sphere" {}\n')
    layer.Save()
  2. Create a proxyShape with the relative path to the file just created
    proxyShape = cmds.createNode("mayaUsdProxyShape")
    cmds.setAttr(f"{proxyShape}.filePath", "someUsdFileInWorkingDir.usda", type="string")
  3. Notice that the path is now stored as absolute
    cmds.getAttr(f"{proxyShape}.filePath")
    # Result: /home/frantzy/someUsdFileInWorkingDir.usda

Specs (if applicable):

Additional context

The issue is very likely due to changes from #3482. Since the filePath attribute is flagged usedAsFileName, this affects behaviour of setAttr.

In our pipeline, we typically rely on environment variables for similar cases, eg file.filteTextureName set to $WORKSPACE_DIR/someImage.exr. Env var substitutions is not yet supported by mayaUsdProxyShape, but the approach could work also for us in this context.

wallworm commented 5 months ago

Thank you for reporting this. The team will discuss.

santosg87 commented 5 months ago

logged this issue internally for investigation on possible next steps.