[MAYA-127758] Setting visibility does not consistently route edits
- Dominant language
- Wolfram Language
- Stars
- 905
- Forks
- 223
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 17
Description
**Describe the bug**
When working on https://github.com/Autodesk/maya-usd/pull/2546, @jallex and I noticed that after we had registered an edit router to route visibility edits to the session layer, setting visibility was not consistently set in the session layer.
**Expected behavior**
We would expect to have visibility routed to the session layer (our routing layer) after we've registered the edit router.
From chatting with our artists, their main workflow for setting visibility is to use Ctrl+h and Shift+h hotkeys. On our side, the Display menu actions and corresponding hotkeys would be the top priority to fix.
Fwiw - they also heavily rely on using Display Layers to toggle visibility.
**Steps to reproduce**
We tested with this PR https://github.com/Autodesk/maya-usd/pull/2546. Then, we created a stage and using the context menu in the outliner, added prims to test with.
Ctrl + h hotkey | Display -> Hide -> Hide Selection menu item | `cmds.hide()`
> If we select a new prim + use action above, it successfully routes visibility edits to the session layer!
>
> If we multi-select an invisible prim (where visibility is authored on the session layer) + a visible prim (where the prim does not have visibility explicitly authored yet), it will hide both and route invisibility to the session layer. However, it also prints the following error:
>
> ` // Error: Cannot edit [visibility] attribute because there is a stronger opinion in [anonymousLayer1-session.usda].
> `
Shift + H hotkey | Ctrl + Shift + H hotkey | Display -> Show -> Show Selection or Show Last Hidden menu items | `cmds.showHidden()`
> If we select an invis prim (where visibility is set on the session layer) + use action above, it does not make the prim invisible and prints the same "stronger opinion" error as above. We would expect visibility to be updated in the session layer and for the prims to be visible.
>
> If we select an invis prim (where visibility is set on the target layer (incorrectly)), it sets visibility=inherited on the session layer and visibility=invisible remains on the target layer.
H hotkey | set visibility using pxr.Usd.Attribute
> To test setting the visibility using an pxr.Usd.Attribute, we used the following code:
```
prim = mayaUsd.ufe.ufePathToPrim(ufe.PathString.string(sceneItem.path()))
visibilityAttr = prim.GetAttribute('visibility')
visibilityAttr.Set(UsdGeom.Tokens.visible) # or UsdGeom.Tokens.invisible
```
> If we select a prim + use action above, it always routes visibility (invis and vis) to the target layer. We would expect visibility to be routed to the session layer.
> If try to vis a prim (where the visibility edit is authored to the session layer) by using the action above, it does not change the visibility in the viewport and does not return the "stronger opinion" error in the script editor.
`cmds.setAttr()` | ufe.PyUfe.AttributeEnnumString
> To test setting the visibility using an ufe.PyUfe.AttributeEnnumString, we used the following code:
```
attrs = ufe.Attributes.attributes(sceneItem)
visibilityAttr = attrs.attribute(UsdGeom.Tokens.visibility)
visibilityAttr.set(UsdGeom.Tokens.visible) # or UsdGeom.Tokens.invisible
```
> To test setting the visibility using `cmds.setAttr()`, we used the following code
```
cmds.setAttr(pathString, UsdGeom.Tokens.visible) # or UsdGeom.Tokens.invisible
```
> It always routes visibility (invis and vis) to the target layer. We would expect visibility to be routed to the session layer.
>
> Except, if trying to vis a prim (where the visibility edit is authored to the session layer), prints the same "stronger opinion" error as above and does not make prim visible.
ufe.Object3d.object3d
> To test setting the visibility using an ufe.Object3d.object3d, we used the following code
```
object3d = ufe.Object3d.object3d(sceneItem)
visibleCmd = object3d.setVisibleCmd(True) # or False
visibleCmd.execute()
```
> If we try to invis a prim, it routes to the session layer as expected!
>
> If we try to vis a prim (where the visibility edit is authored on the session layer), it prints the same "stronger opinion" error as above and does not make prim visible.
> If we try to vis a prim (where there are not any visibility edits), it does not author any information.
**Specs (if applicable):**
- Maya version 2023.1
- Maya USD commit SHA [dev at 023a7d850d1cd2f78ebd51ed1a36846baa51c935] + PR #2546
- Pixar USD commit SHA [dev at 8dcb0c2]
Pixar Jira: MAYA-3451
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.