Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ufe.PathString.path returns incorrect path if given path starts with |world #3822

Closed
ika-rporter opened this issue Jun 12, 2024 · 8 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@ika-rporter
Copy link
Contributor

Describe the bug
The ufe.PathString.path function returns incorrect path if the given path starts with |world

Steps to reproduce

  1. Open Maya
  2. Create this transform hierarchy: |world|foo|bar
  3. Select bar
  4. Run the snippet below
  5. Observe the error when trying to construct a ufe.SceneItem with the path.
import ufe

ufePath_1 = ufe.PathString.path('|world|foo|bar')
ufePath_1.segments[0]
print(ufePath_1)
# |world|foo|bar

ufePath_2 = ufe.GlobalSelection.get().front().path()
print(ufePath_2)
# |world|world|foo|bar

ufe.SceneItem(ufePath_1)
# # Error: pybind11::init(): factory function returned nullptr

We can work around this by remembering to prepend |world to all of our DAG paths it's just ... annoying. Worst case, we change the name of our scene root to something other than world.

Expected behavior
The ufe.PathString.path function should return the correct path

Specs (if applicable):

  • Rocky 9
  • Maya 2023.3
@ika-rporter ika-rporter added the bug Something isn't working label Jun 12, 2024
@seando-adsk
Copy link
Collaborator

seando-adsk commented Jun 12, 2024

You should not create a ufe scene item directly by using the constructor. The problem here is that it won't create the derived class which is a Maya scene item. Instead you should always use the Hierarchy.createItem() method.

item = ufe.Hierarchy.createItem(ufePath_1)
print(item)
# <ufe.PyUfe.SceneItem object at 0x0000028CAEB5A1B0>
print(item.path())
# |world|foo|bar

Sean

@ika-rporter
Copy link
Contributor Author

I think my example was not clear - |world|foo|bar is the DAG path of a node in the scene, not the implicit UFE root. See screenshot.

image

I created the test scene like so:

cmds.createNode('transform', 'world')
cmds.createNode('transform', 'foo', parent='world')
cmds.createNode('transform', 'bar' parent='bar')

The example in your comment only works if ufePath_1 = ufe.PathString.path('|foo|bar'); otherwise it returns None

@seando-adsk
Copy link
Collaborator

Ah sorry I missed from your example. Maya Ufe paths must unconditionally have "world" added as a prefix, regardless of whether they start with "world" or not. This is because in Maya the root node is called "world".

import maya.api.OpenMaya as om
it = om.MItDag()
root = it.currentItem()
om.MFnDependencyNode(root).name()
# Result: world

Sean

@ika-rporter
Copy link
Contributor Author

So if you have a literal DAG node in Maya named '|world', you need to prepend the root world so you have |world|world|foo|bar? Or change our pipeline so our explicit root is called something else? :)

@seando-adsk
Copy link
Collaborator

Unfortunately that is correct. We have a bug logged for that already:
MAYA-131348 - Naming nodes "world" breaks Ufe workflow

In Maya every DAG node is parented to a node called "world". That node is implicit and hidden and Maya knows about it so that is why you don't need to specify it.

In Ufe when dealing with Maya paths we are conditionally added "world" to the path if it is not present. That is the bug. We should be unconditionally adding world. The preferred workaround for you is to not create a node called "world" as the root of your scene. If you add an extra "world" in your paths, if and when we fix the bug, we would break your workaround.

Sean

@ika-rporter
Copy link
Contributor Author

Understood. I will forward this to our VFX supes and let them decide if we want to rename the root prim in out scenes. Thank you.

@santosg87
Copy link
Collaborator

santosg87 commented Jun 19, 2024

Just a note here, that this fix would require changes on the maya side, so a new version of maya would be needed in order to see the fix.

@santosd santosd closed this as completed Jun 21, 2024
@santosd santosd reopened this Jun 21, 2024
@santosd
Copy link
Collaborator

santosd commented Jun 21, 2024

Going to go ahead and close this one for now, @ika-rporter if anything else comes up, let use know and we can reopened the issue or feel free to log a new issue if it is a different topic.

@santosd santosd closed this as completed Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants