maya-usd icon indicating copy to clipboard operation
maya-usd copied to clipboard

Saving layers/stage from MayaUsdProxyShape does not author Up Axis

Open BigRoy opened this issue 1 year ago • 1 comments

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:

  1. Create a new empty Maya USD Proxy Shape.
  2. Create few layers
  3. Save root layer and extra layers
  4. 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)

BigRoy avatar Dec 11 '23 20:12 BigRoy

Improving both axis and scale awareness in MayaUSD is on our roadmap. We will address this in that work.

wallworm avatar Dec 13 '23 15:12 wallworm