SdfLayer_UsdStage
ipynbFile SdfLayer_01__SdfLayer_UsdStage.ipynb
In [52]:
| from pxr import Usd,Sdf
import os
|
In [53]:
| layer = Sdf.Layer.CreateAnonymous()
layer.Reload()
|
In [54]:
| spec = Sdf.CreatePrimInLayer(layer,'/sample')
|
In [55]:
| print(layer.ExportToString())
|
Success
| #sdf 1.4.32
over "sample"
{
}
|
In [56]:
| # MetaDataの一覧を表示
print(spec.GetMetaDataInfoKeys())
|
Success
| ['apiSchemas', 'suffixSubstitutions', 'active', 'symmetryArguments', 'assetInfo', 'instanceable', 'customData', 'displayGroupOrder', 'documentation', 'hidden', 'kind', 'payload', 'permission', 'clips', 'prefix', 'prefixSubstitutions', 'suffix', 'symmetricPeer', 'symmetryFunction', 'typeName', 'sample_metadata', 'payloadAssetDependencies', 'inactiveIds', 'clipSets', 'sdrMetadata']
|
In [57]:
1
2
3
4
5
6
7
8
9
10
11
12
13 | # PrimSpec
spec.GetObjectAtPath('/sample')
print(spec.attributes)
print(spec.properties)
spec.customData
print(spec.nameRoot)
print(spec.payloadList)
print(spec.referenceList)
print(spec.relationships)
print(spec.specifier)
print(spec.kind)
# overではなく defにする
spec.specifier = Sdf.SpecifierDef # Defaultは Sdf.SpecifierOver
|
Success
| {}
{}
Sdf.Find('anon:0000020E4E1F5600', '/')
{ 'added': []'prepended': []'appended': [], 'deleted': [], 'ordered': [] }
{ 'added': []'prepended': []'appended': [], 'deleted': [], 'ordered': [] }
{}
Sdf.SpecifierOver
|
In [59]:
| print(layer.ExportToString())
|
Success
| #sdf 1.4.32
def "sample"
{
}
|
In [60]:
| # Stageを使用してLayerを操作
stage = Usd.Stage.Open(layer)
prim = stage.DefinePrim('/sampleB')
|
In [61]:
| print(layer.ExportToString())
|
Success
| #sdf 1.4.32
def "sample"
{
}
def "sampleB"
{
}
|
In [73]:
| # Referenceを指定
prim.GetReferences().AddReference(f'{os.getcwd()}/usd/sample.usda')
# Attribute追加
attr = prim.CreateAttribute('hoge',Sdf.ValueTypeNames.String)
attr.Set("fugafuga")
|
In [63]:
| print(layer.ExportToString())
|
Success
| #sdf 1.4.32
def "sample"
{
}
def "sampleB" (
prepend references = @c:\reincarnation_tech\notebooks\USD\Stage/usd/sample.usda@
)
{
}
|
In [68]:
| # LayerからPrimSpecを取得して、referenceを取得する
specB = layer.GetPrimAtPath('/sampleB')
print(specB.referenceList)
|
Success
| { 'added': []'prepended': [SdfReference(c:\reincarnation_tech\notebooks\USD\Stage/usd/sample.usda, , SdfLayerOffset(0, 1), {})]'appended': [], 'deleted': [], 'ordered': [] }
|
In [90]:
| # SpecからAttribute取得
attrSpec = specB.attributes['hoge']
|
In [91]:
| # AttributeNameを取得
print(attrSpec.name)
# Specから値を取得
print(attrSpec.default)
|
最終更新日:
2022-06-15 15:26:59