ipynbFile USDAttribute_connections.ipynb
AttributeのConnectionを試す
In [3]:
In [8]:
| stage = Usd.Stage.CreateInMemory()
stage.Reload()
|
In [24]:
| prim = stage.DefinePrim("/Sample")
attr = prim.CreateAttribute('hoge',Sdf.ValueTypeNames.Int)
attr.Set(10)
primB = stage.DefinePrim("/srcPrim")
attrB = primB.CreateAttribute("src",Sdf.ValueTypeNames.Int)
attrB.Set(100)
|
In [12]:
| # アトリビュートのコネクションをする
attr.AddConnection(attrB.GetPath())
print(stage.ExportToString())
|
Success
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | #usda 1.0
(
doc = """Generated from Composed Stage of root layer
"""
)
def "Sample"
{
custom int hoge = 10
int hoge.connect = </srcPrim.src>
}
def "srcPrim"
{
custom int src = 100
}
|
In [17]:
| # 接続先のアトリビュートを取得すると、そのSdfPathがとれるので
# それを利用して接続先の値を取得
print(attr.GetConnections())
# 接続先の値を取得
for i in attr.GetConnections():
attr = stage.GetAttributeAtPath(i)
print(attr.Get())
|
In [35]:
1
2
3
4
5
6
7
8
9
10
11
12 | # コンポジションする場合
stageB = Usd.Stage.CreateInMemory()
layer = stageB.GetRootLayer()
layer.subLayerPaths = [stage.GetRootLayer().identifier]
primB = stageB.DefinePrim("/srcPathB")
attrB = primB.CreateAttribute("srcB",Sdf.ValueTypeNames.Int)
attrB.Set(1000)
print(attrB.GetPath())
toAttr = stageB.GetAttributeAtPath("/Sample.hoge")
toAttr.AddConnection(attrB.GetPath())
|
In [38]:
| print(toAttr.GetConnections())
print(toAttr.HasAuthoredConnections())
print(stageB.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
24
25
26
27
28 | [Sdf.Path('/srcPathB.srcB'), Sdf.Path('/srcPrim.src')]
#usda 1.0
(
doc = """Generated from Composed Stage of root layer
"""
)
def "Sample"
{
custom int hoge = 10
int hoge.connect = [
</srcPathB.srcB>,
</srcPrim.src>,
]
}
def "srcPrim"
{
custom int src = 100
}
def "srcPathB"
{
custom int srcB = 1000
}
True
|