# %%
from pxr import Usd, UsdGeom, Sdf, Gf
USD_PATH_ROOT = "I:/usd_test"
kitchenSetRoot = USD_PATH_ROOT + "/Kitchen_set/assets/"
stage = Usd.Stage.CreateInMemory()
# この場合はPrimになるし
refPrimA = stage.DefinePrim("/World/BookGrp/Book")
refPrimB = stage.DefinePrim("/World/BookGrp/BookB")
# この場合はGeomになる
# 指定のPrimに対してReferenceを読み込み
refPrimA.GetReferences().AddReference(kitchenSetRoot + 'Book/Book_payload.usd')
refPrimB.GetReferences().AddReference(kitchenSetRoot + 'Book/Book_payload.usd')
# %%
# 読み込んだリファレンスモデルに対してTransformを実行
xfA = UsdGeom.Xform(refPrimA)
xfA.AddRotateXOp().Set(90)
xfB = UsdGeom.Xform(refPrimB)
xfB.AddRotateXOp().Set(90)
xfB.AddTranslateOp().Set((50, 0, 0))
# %%
print(stage.GetRootLayer().ExportToString())
# %%
stage.GetRootLayer().Export(USD_PATH_ROOT + "/refTest.usda")