How to set collection:membershipExpression

   573   2   1
User Avatar
Member
18 posts
Joined: June 2018
Offline
From what I understand, collections in USD can specify membership in either relationship-mode or expression-mode. I have a case that might benefit from using expression-mode, but I wonder how to access that in Solaris?

I can set the required collection:membershipExpressionwith a Python LOP, but I feel I might be missing something obvious (an option on the Collection LOP?)
Edited by Dan_Andersen - Dec. 18, 2024 02:43:01
User Avatar
Member
18 posts
Joined: June 2018
Offline
This is how I'm doing it now. Just wondering if it's the best/only way?

Edited by Dan_Andersen - Dec. 20, 2024 04:21:29

Attachments:
exprColl_python.png (337.2 KB)

User Avatar
Member
75 posts
Joined: July 2006
Offline
I'm not sure this is possible as I've tried the same thing.

Theoretically I believe this should work

https://openusd.org/dev/user_guides/collections_and_patterns.html#configuring-pattern-based-collections [openusd.org]

collectionPrim = stage.DefinePrim("/CollectionPrim")
myCollection = Usd.CollectionAPI.Apply(collectionPrim, "myCollection")
myCollection.CreateExpansionRuleAttr(Usd.Tokens.expandPrims)
pathExp = Sdf.PathExpression("/World/Light*{hasAPI:LightAPI}")
expressionAttr = myCollection.CreateMembershipExpressionAttr(pathExp)

But the Sdf object doesn't have CreateExpansionRuleAttr() or PathExpression(). It might be a usd version thing but that's as far I got for now
john @ goodbyekansas
  • Quick Links