Is there any way for python to access and manipulate the groupings (from a Group SOP) of primitives/points/vertices in a Script SOP?
Unfortunately, this is not available in the Script SOP at this time.
One workaround is to tag those points with some attribute (color, large Z value etc), which can be accessed during the Script SOP.
Cheers,
Rob.
I ended up using custom attributes (e.g. āsideā, ālayerā, āpaneltypeā, etc).
There seem to be a a few limitations to the process of creating groups (like only one group created per Group SOP as far as I can tell), but theyāre really useful in terms of filtering the effects of SOPs, so it would be great to expand the other functionality around them.
Is this something thatās likely not to be implemented?
It would at least be useful to be able to access group membership from a SOP To DAT or something similar.
Itās on our near term roadmap to provide script access to SOP Groups.
Adding it to the DAT tables is also a great idea.
Weāll put that on the list.
Thanks!
Itāll be super useful for this project (which Iāll post about in detail at some point):
[video]https://vimeo.com/329275680[/video]
It uses grouping to define which shapes various attributes get applied to. Currently Iām just doing most of that by copying the group memberships to attributes, but there ends up being manual work since you canāt yet determine which groups need to be converted to attributes.
Looks awesome.
Are you getting sufficient performance with any python scripting this will use?
My strategy in general is to avoid putting chunks of Python into the main pipeline thatās cooking every frame, except for expressions that get optimized (the optimization is awesome btw).
So in this case thereās a phase where a pattern is loaded from files and it pre-calculates as much as it can about group memberships, various other attributes, maybe neighboring shapes at some point. That produces a SOP with a bunch of attributes plus a few kinds of CHOP/DAT lookup tables.
Once thatās loaded, the rendering part and applying settings to the shapes is mostly done in a shader (except some transform stuff that I havenāt gotten working yet which is done in a Primitive SOP).
It ends up being quite fast after it loads (which so far only takes a few frames).
Might write something more detailed about that strategyā¦
Thatās great info.
Just a note: There currently is a group parameter in the SOP to DAT, which filters the rows to those elements in the specified groups.
Weāre looking to expand that to a column called āgroupsā, with a list of groups each element belongs to, for each cell.
Is that what you had in mind?
-Rob
Yes, that would work!
Direct script access would be a nice bonus (particularly also being able to create/modify groups), but the DAT would do the trick.
Any example you could upload of this? Iām trying to figure out a way to randomly select a group of vertices within an SOP group so it doesnāt look so āperfectā when I instance objects from those selected points.
Any advice would be welcome.
You could use a sort SOP with a random ordering and then take the first N points. If nothing depends on the order later on, you can just leave it like that.
If you do need to keep the ordering, you could do something like a Group SOP with an expression that uses a random value (such as from a Noise CHOP) to decide whether each point is in the group.
random_point_grouping_example.toe (4.0 KB)
That is exactly what I was looking for. Much appreciated!
Any further development on this topic?
Iām in search of a way to have a script operate on the respective primitives independently, for example by transforming them.
E: Havenāt quite implemented what I had in mind (yet) but this tutorial was helpful to get started with sop scripting https://www.youtube.com/watch?v=x8lDfTFSass
E2: Iāve had some success by simply taking another SOP to DAT for the primitives of the respective SOP and using it in the downstream SOPās onCook method.