ScriptSOP and primitive/point/vertex groups

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)

1 Like

That is exactly what I was looking for. Much appreciated!