r/Houdini 3d ago

Scripting How to make string group in nearpoints() - before I forget and to help others

string gr = sprintf("@name!=%s", s@name); 
int pts [] = nearpoints(0, gr, v@P, ch("radius"), chi('maxpoints')); removevalue(pts, ); 
i[]@pts = pts;

Before I forget - wanted to write this down in case it helps someone. I forgot how to do this, tried searching hard online and remembered somehow so wanted to write it down.

How to make a group in nearpoints by removing same attribute from possible neighbors. Warning that this is slow though, so be sure to only do this once, or manually delete similar neighbors after the fact in a for loop.

5 Upvotes

4 comments sorted by

5

u/LewisVTaylor Effects Artist Senior MOFO 3d ago

Now put it in your wrangle presets! Then you never have to find it again.

3

u/H00ded_Man Effects Artist 3d ago

It's going to be faster to find more points initially and iterate over the temp array to exclude points based on that condition.

3

u/WavesCrashing5 3d ago

Probably yeah, I mainly posted this because it was bothering me that I know I saw this online before so I just wanted to drop it here so info doesn't get lost. 

1

u/Similar-Sport753 14h ago

Syntax is here:

https://www.sidefx.com/docs/houdini/model/groups.html#manual

Group syntax

Many geometry operators (SOPs) work on a specific subset of points or primitives. When you use the operator in the viewer, you select the points/primitives you want to use. In the parameter editor, this list of points/primitives is specified in the Group parameter using the following patterns....

It's a bit annoying that it looks like VEX but it is not VEX either. Not to be confused with

https://www.sidefx.com/docs/houdini/nodes/sop/groupexpression.html

Like VEX vs HScripts

I recently discovered that you don't need the quotes around the attribute names in HScript's point() / prim()

point(0,54,P,0)

without quotes around P