maya-usd
maya-usd copied to clipboard
String-ified ufe.Path cannot be used to recreate the path using ufe.PathString in Python
Describe the bug
When an instance of ufe.Path
in Python is string-ified using str()
, the resulting string is missing the comma separator between the Maya segment and the USD segment. This string then cannot be used to recreate an instance of ufe.Path
using ufe.PathString.path()
that would then return the same scene item using ufe.Hierarchy.createItem()
.
This may be an issue in UFE as opposed to maya-usd.
Steps to reproduce
This should be reproducible with any USD exposed by a mayaUsdProxyShape
, but for the purposes of this test, I used the USD here:
https://github.com/Autodesk/maya-usd/blob/dev/test/lib/usd/translators/UsdImportExportScopeTest/Scopes.usda
Steps to reproduce the behavior:
- Load the
mayaUsdPlugin
- Create -> USD -> Stage from file..., and pick a layer to create the proxy
- In the outliner, select a USD prim underneath the proxy
- Then in the script editor:
import ufe
# Get the SceneItem and its Path from the selection
sceneItem = list(ufe.GlobalSelection.get())[0]
ufePath = sceneItem.path()
ufePathString = str(ufePath)
print("ufePathString: %s" % ufePathString)
# In my case, this printed something like:
# ufePathString: |world|Scopes|ScopesShape/A/A_1
#
# Notice the comma missing between the Maya segment "|world|Scopes|ScopesShape" and the USD segment "/A/A_1"
# Try to use ufePathString to re-fetch the SceneItem
newUfePath = ufe.PathString.path(ufePathString)
newSceneItem = ufe.Hierarchy.createItem(newUfePath)
print(newSceneItem is None)
# That should print True, so we failed to get the SceneItem with the reconstructed path.
# If we correct the path string to insert the comma, we're able to get the SceneItem:
ufePathString = '|world|Scopes|ScopesShape,/A/A_1'
newUfePath = ufe.PathString.path(ufePathString)
newSceneItem = ufe.Hierarchy.createItem(newUfePath)
print(newSceneItem is None)
# That should then print False
Expected behavior
String-ifiying a ufe.Path
should return a string that can then be used to recreate the exact same ufe.Path
.
Specs (if applicable):
- OS & version: Linux RHEL 7.8
- Compiler & version: gcc 6.3.1
- Maya version: PR 120
- Maya USD commit SHA: https://github.com/Autodesk/maya-usd/commit/a83cfc1350a485f30cc378f1e1568ed7cba6a463
- Pixar USD commit SHA: https://github.com/PixarAnimationStudios/USD/commit/f7b5f25e0d7bd951439485841304aa430683ab23