目次:
Maya USD Plugin Document
https://github.com/Autodesk/maya-usd/blob/dev/README_DOC.md
Maya USD Commands
https://github.com/Autodesk/maya-usd/blob/dev/lib/mayaUsd/commands/Readme.md
Maya 内で Pixar USD Workflow
https://github.com/Autodesk/maya-usd/discussions/2254
nVidia : Import Reference
https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/usd/references-payloads/add-reference.html
Create the stage:
import mayaUsd.ufe
import mayaUsd.lib
import mayaUsd_createStageWithNewLayer
import ufe
from pxr import Usd, UsdGeom, Gf
usdSeparator = '/'
psPathStr = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
psPath = ufe.PathString.path(psPathStr)
ps = ufe.Hierarchy.createItem(psPath)
stage = mayaUsd.lib.GetPrim(psPathStr).GetStage()
aPrim = stage.DefinePrim('/A', 'Xform')
aXformable = UsdGeom.Xformable(aPrim)
aXlateOp = aXformable.AddTranslateOp()
aXlation = Gf.Vec3d(1, 2, 3)
aXlateOp.Set(aXlation)
aUsdUfePathStr = psPathStr + ',/A'
aUsdUfePath = ufe.PathString.path(aUsdUfePathStr)
aUsdItem = ufe.Hierarchy.createItem(aUsdUfePath)
bPrim = stage.DefinePrim('/A/B', 'Cube')
bXformable = UsdGeom.Xformable(bPrim)
bXlateOp = bXformable.AddTranslateOp()
bXlation = Gf.Vec3d(7, 8, 9)
bXlateOp.Set(bXlation)
bUsdUfePathStr = aUsdUfePathStr + '/B'
bUsdUfePath = ufe.PathString.path(bUsdUfePathStr)
bUsdItem = ufe.Hierarchy.createItem(bUsdUfePath)
Pixar USD Python Tutoria
USD Tutorials — Universal Scene Description 23.08 documentation
Maya Pixar USD Example
https://github.com/Autodesk/maya-usd/blob/dev/test/testUtils/usdUtils.py
nVidia : Working with USD Python Libraries
Working with USD Python Libraries
USDファイルをリファレンスで読み込み(Create stage from file)
※ コードは検証中のもの
#-----------------------------------#
# """ Import Maya Python """
#-----------------------------------#
import maya.cmds as cmds
#-----------------------------------#
# """ Import Maya USD Modules """
#-----------------------------------#
import mayaUsd.ufe
import mayaUsd.lib
import mayaUsd_createStageWithNewLayer
import ufe
from pxr import Usd, UsdGeom, Gf
#-----------------------------------#
# Settings
#-----------------------------------#
MAYA_USD_STAGE_NAME = '|stage1|typ_stage'
#-----------------------------------#
# Main
#-----------------------------------#
""" get maya stage """
maya_stage = None
if cmds.objExists(MAYA_USD_STAGE_NAME):
maya_stage = MAYA_USD_STAGE_NAME
else:
maya_stage = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
cmds.rename(maya_stage, 'typ_stage')
""" get usd stage from maya obj """
# ps_path = ufe.PathString.path(MAYA_USD_STAGE_NAME)
# ps = ufe.Hierarchy.createItem(ps_path)
print(f'TYP | stage = {MAYA_USD_STAGE_NAME}')
# print(f'TYP | ps_path = {ps_path}')
# print(f'TYP | ps = {ps}')
""" reference usd file """
asset_name = 'MyAsset'
usd_file = 'my_usd_v0003.usd'
stage = mayaUsd.lib.GetPrim(MAYA_USD_STAGE_NAME).GetStage()
my_prim = stage.DefinePrim(f'/{asset_name}')
my_prim.GetReferences().AddReference(usd_file)