USDAssetsの作り方、基本構造メモ
ipynbFile makefileVariant__USDAssetsの作り方、基本構造メモ.ipynb
USDのサンプル examples/usdMakeFileVariantModelAsset/usdMakeFIleVarinatModelAsset.py
の中身を確認する。
このサンプルはコマンドラインで実行できる。
python usdMakeFileVariantModelAsset\usdMakeFileVariantModelAsset.py  --kind model  -i D:/test.usda -v cube sphere testProps D:\USDsample\modelAsset\cube.usda D:\USDsample\modelAsset\sphere.usda
基本構造は

RootPrim - Variant - Payload - 
         - __class_assetName
VariantとPayloadとInheritsの組み合わせ。
以下はサンプルの気になる部分の実行テスト。
In [1]:
 | from pxr import Tf, Kind, Sdf, Usd 
  | 
 
In [2]:
 | Tf.IsValidIdentifier('sample')
  | 
 
In [3]:
In [4]:
 | filename = f"D:/{assetName}.usd"
  | 
 
In [5]:
 | layer = Sdf.Layer.CreateNew(filename,args= {'format':'usda'})
  | 
 
In [6]:
 | stage = Usd.Stage.Open(layer)
  | 
 
In [9]:
 | print(rootPath.AppendChild(assetName))
  | 
 
In [10]:
 | rootPath = Sdf.Path.absoluteRootPath
modelRootPrim = stage.DefinePrim(rootPath.AppendChild(assetName))
  | 
 
In [27]:
 | modelAPI = Usd.ModelAPI(modelRootPrim)
  | 
 
In [28]:
 | # Option用のResolvePathをセットする
# (あくまでもOptionとして使用されるもの?もの?)
modelAPI.SetAssetIdentifier('D:/test.usda')
# AssetPathで取得できる
print(modelAPI.GetAssetIdentifier())
modelAPI.SetAssetName(assetName)
  | 
 
In [39]:
 | # 引数で指定したKindかどうかを判定
modelAPI.IsKind('model')
  | 
 
In [40]:
 | classPrim = stage.CreateClassPrim(rootPath.AppendChild("_class_"+assetName))
modelRootPrim.GetInherits().AddInherit(classPrim.GetPath())
  | 
 
In [42]:
 | print(stage.GetRootLayer().ExportToString())
  | 
 
Success
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18  | #usda 1.0
(
    defaultPrim = "sampleData"
)
def "sampleData" (
    assetInfo = {
        asset identifier = @D:/test.usda@
    }
    prepend inherits = </_class_sampleData>
    kind = "model"
)
{
}
class "_class_sampleData"
{
}
  |