Skip to content

Commit

Permalink
Merge pull request #3229 from Autodesk/bailp/EMSUSD-252/relative-payl…
Browse files Browse the repository at this point in the history
…oad-preview

EMSUSD-252 relative payload preview
  • Loading branch information
seando-adsk authored Jul 17, 2023
2 parents 81704ad + 79e0baf commit df33b99
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions plugin/adsk/scripts/mayaUsd_USDRootFileRelative.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class usdFileRelative(object):
# Note: are initialized in the uiInit() method.
_canBeRelative = False
_haveRelativePathFields = False
_parentLayerPath = ""
_relativeToDir = ""
_relativeToScene = False
_ensureUsdExtension = True

@staticmethod
Expand Down Expand Up @@ -250,9 +251,9 @@ def updateFilePathPreviewFields(cls, makePathRelative=None):
unresolvedPath = selectedFile

relativePath = ''
if unresolvedPath and cls._parentLayerPath:
relativePath = mayaUsdLib.Util.getPathRelativeToDirectory(unresolvedPath, cls._parentLayerPath)
elif unresolvedPath:
if unresolvedPath and cls._relativeToDir:
relativePath = mayaUsdLib.Util.getPathRelativeToDirectory(unresolvedPath, cls._relativeToDir)
elif unresolvedPath and cls._relativeToScene:
relativePath = mayaUsdLib.Util.getPathRelativeToMayaSceneFile(unresolvedPath)
cmds.textFieldGrp(cls.kUnresolvedPathTextField, edit=True, text=relativePath)

Expand Down Expand Up @@ -290,6 +291,7 @@ def uiInit(cls, parentLayout, filterType):
# If the latter doesn't exist, we use a special approach with
# postponed relative file path assignment
cls.setRelativeFilePathRoot(cmds.file(query=True, sceneName=True))
cls._relativeToScene = True
super(usdRootFileRelative, cls).uiInit(parentLayout, True, cls.kRelativeToWhat)

@classmethod
Expand Down Expand Up @@ -320,8 +322,8 @@ def uiInit(cls, parentLayout, filterType, parentLayerPath = ""):
with the dialog2 command API.
'''

cls._parentLayerPath = parentLayerPath
canBeRelative = bool(usdFileRelative.getRelativeFilePathRoot())
cls._relativeToDir = parentLayerPath
canBeRelative = bool(cls._relativeToDir)
super(usdSubLayerFileRelative, cls).uiInit(parentLayout, canBeRelative, cls.kRelativeToWhat)

@classmethod
Expand Down Expand Up @@ -351,8 +353,9 @@ def uiInit(cls, parentLayout, filterType):
Note: the function takes an unused filterType argument to be compatible
with the dialog2 command API.
'''
cls._relativeToDir = usdFileRelative.getRelativeFilePathRoot()
# If there is no target layer saved, then the checkbox and label should be disabled.
canBeRelative = bool(usdFileRelative.getRelativeFilePathRoot())
canBeRelative = bool(cls._relativeToDir)
super(usdFileRelativeToEditTargetLayer, cls).uiInit(parentLayout, canBeRelative, cls.kRelativeToWhat)

@classmethod
Expand Down

0 comments on commit df33b99

Please sign in to comment.