Skip to content

Commit

Permalink
Prepare code for renaming inside variant edit context/target - but ke…
Browse files Browse the repository at this point in the history
…ep commented for now due to what looks like a USD bug: https://forum.aousd.org/t/perform-namespace-edit-inside-a-variant-set-edit-target/1006
  • Loading branch information
BigRoy committed Dec 1, 2023
1 parent 5e55317 commit 8848d47
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion usd_qtpy/lib/usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,25 @@ def rename_prim(prim: Usd.Prim, new_name: str) -> bool:
return True

prim_path = prim.GetPath()
new_prim_path = prim_path.GetParentPath().AppendChild(new_name)
new_prim_path = prim_path.ReplaceName(new_name)

# We want to map the path to the current edit target of its stage so that
# if the user is renaming a prim in an edit target currently editing
# within a variant set, that we rename that particular opinion. However,
# we only do that if the source prim path existed in the edit target
# otherwise we will edit it on the layer regularly
# WARNING This will crash on calls to `prim.GetPrimStack()` afterwards
# See: https://forum.aousd.org/t/perform-namespace-edit-inside-a-variant-set-edit-target/1006
# stage = prim.GetStage()
# edit_target = stage.GetEditTarget()
# remapped_prim_path = edit_target.MapToSpecPath(prim_path)
# if (
# prim_path != remapped_prim_path
# ):
# logging.debug("Remapping prim path to within edit target: %s",
# remapped_prim_path)
# prim_path = remapped_prim_path
# new_prim_path = edit_target.MapToSpecPath(new_prim_path)

stage = prim.GetStage()
with Sdf.ChangeBlock():
Expand Down

0 comments on commit 8848d47

Please sign in to comment.