Referenceをつくる
ipynbFile UsdReference2__Referenceをつくる.ipynb
In [16]:
In [10]:
| stage = Usd.Stage.CreateInMemory()
prim = stage.DefinePrim("/sphereTest")
|
In [11]:
| # ファイルを指定してリファレンスを追加
prim.GetReferences().AddReference(f"{os.getcwd()}/usd/sphere.usda")
|
In [20]:
| layer = Sdf.Layer.FindOrOpen("usd/sphere.usda")
# 中身
print(layer.ExportToString())
|
Success
| #usda 1.0
(
defaultPrim = "sphere"
)
def Sphere "sphere"
{
}
|
In [13]:
| print(stage.GetRootLayer().ExportToString())
|
Success
| #usda 1.0
def "sphereTest" (
prepend references = @c:\reincarnation_tech\notebooks\USD\CompArc/usd/sphere.usda@
)
{
}
|
In [12]:
| # Flattenした結果
print(stage.Flatten().ExportToString())
|
Success
| #usda 1.0
(
doc = """Generated from Composed Stage of root layer
"""
)
def Sphere "sphereTest"
{
}
|
In [21]:
| primB = stage.DefinePrim('/referenceCube')
|
In [25]:
| # DefaultPrimが指定されていないような場合
print(Sdf.Layer.FindOrOpen(f"{os.getcwd()}/usd/cube.usda").ExportToString())
|
Success
| #usda 1.0
def Xform "root"
{
def Cube "sampleCube"
{
}
}
|
In [22]:
| # AddReferenceで、どのPrimをリファレンスするのか指定する
primB.GetReferences().AddReference(f"{os.getcwd()}/usd/cube.usda",Sdf.Path("/root"))
|
In [23]:
| print(stage.GetRootLayer().ExportToString())
|
Success
1
2
3
4
5
6
7
8
9
10
11
12
13 | #usda 1.0
def "sphereTest" (
prepend references = @c:\reincarnation_tech\notebooks\USD\CompArc/usd/sphere.usda@
)
{
}
def "referenceCube" (
prepend references = @c:\reincarnation_tech\notebooks\USD\CompArc/usd/cube.usda@</root>
)
{
}
|
In [27]:
| refPrim = stage.DefinePrim("/refPrim")
refPrim.CreateAttribute('sampleValue',Sdf.ValueTypeNames.String).Set("hogehoge")
primC = stage.DefinePrim("/addRef")
# 現在のStage以下のPrimをリファレンス
primC.GetReferences().AddInternalReference(refPrim.GetPath())
|
In [29]:
| print(stage.Flatten().ExportToString())
|
Success
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | #usda 1.0
(
doc = """Generated from Composed Stage of root layer
"""
)
def Sphere "sphereTest"
{
}
def "referenceCube"
{
}
def "refPrim"
{
custom string sampleValue = "hogehoge"
}
def "addRef"
{
custom string sampleValue = "hogehoge"
}
|