Hi
I'm trying to create collection using following code:
node = hou.pwd()
stage = node.editableStage()
from pxr import Usd
c = Usd.CollectionAPI(stage.GetPrimAtPath('/collections'), 'dupxo')
inc = c.CreateIncludesRel()
inc.AddTarget('/sphere1')
c.CreateExcludesRel()
c.CreateExpansionRuleAttr(Usd.Tokens.explicitOnly)
c.CreateIncludeRootAttr()
In scene graph, it looks like the collection gets created. But it doesn't appear in primitives field menu. What am I missing in my script?
Creating collections using Python
1303 3 0- Tomek P
- Member
- 11 posts
- Joined: 1月 2015
- Offline
- Tomek P
- Member
- 11 posts
- Joined: 1月 2015
- Offline
- mtucker
- スタッフ
- 4525 posts
- Joined: 7月 2005
- Offline
You python code isn't correctly creating the CollectionAPI. To add a new collection to a prim, you need to call UsdCollecitonAPI::Apply (https://openusd.org/dev/api/class_usd_collection_a_p_i.html#a4c9c1226d01a049864cc0d437900c458). This adds the metadata to the prim indicating that the collection exists. The code you've written just creates some attributes that are associated with a collection with a particular name, but doesn't actually register the collection instance on the prim.
- Tomek P
- Member
- 11 posts
- Joined: 1月 2015
- Offline
-
- Quick Links