maya-usd
maya-usd copied to clipboard
Saving layers/stage from MayaUsdProxyShape does not author Up Axis
Describe the bug
There currently doesn't seem to be a way via the UI to set a root layer or layer's up axis in the Layer Editor for a MayaUsdProxyShape. Maya uses the Y-axis as up axis by default I suppose (since Maya is oriented that way) however still it'd be good practice to include the up-axis in the exported layer as an authored opinion. And it should still be up to user control to set a different up axis if needed.
Steps to reproduce Steps to reproduce the behavior:
- Create a new empty Maya USD Proxy Shape.
- Create few layers
- Save root layer and extra layers
- None of the layers have an authored up axis.
Expected behavior
Likely best to at least have the root layer default to an authored Y up axis (if created new) and better even to expose functionality to set it it via the UI (and also easily visualize the up-axis if needed)
Attachments
n/a
Specs (if applicable):
- OS & version n/a
- Maya version 2024.2
- Maya USD 0.26.0
Additional context
Related conversation on USD Alliance Forum with @spiffmon pointing out it's likely lacking due to oversight and thus report here, et voila.
Maya USD does author an opinion when doing export selected from regular maya geometry, but not from a maya usd proxy shape.
It might also be that the feature does exist for maya usd proxy shape but it's just missed by me where it's at.
Workaround
For now a temporary workaround would be to author the opinion via the USD Python API, e.g.
# 1. Select a MayaUsdProxyShape or select Usd Prim via Maya UFE
# 2. Run this script to set stage root layer up axis to Y-axis
from maya import cmds
import mayaUsd
from pxr import UsdGeom
def get_selected_stage():
for path in cmds.ls(selection=True, ufeObjects=True, long=True):
proxy = path.split(",", 1)[0]
stage = mayaUsd.ufe.getStage("|world" + proxy)
if stage:
return stage
raise RuntimeError("No proxy found in selection")
stage = get_selected_stage()
axis: UsdGeom.Tokens = UsdGeom.Tokens.y
print(f"Setting up axis for '{stage.GetRootLayer().GetDisplayName()}' to {axis}")
UsdGeom.SetStageUpAxis(stage, axis)
Improving both axis and scale awareness in MayaUSD is on our roadmap. We will address this in that work.