# Find connected primitives

## Recommended Posts

Hello all!
How can I find all connected primitives to given prim in big polygon mesh? For example if I have prim number 10 and want find surrounding prims.

Thank you very much!!!

##### Share on other sites

Here's one idea, use a Connectivity SOP and then group all primitives that have the same \$CLASS attribute value:

ee_select_brothers.hip

Edited by eetu

##### Share on other sites

Oh, or did you mean just the immediate connected neighbours? In that case use the primneighbours() expression like this. If you only want ones that share an edge and not just a point, use 2 as the third argument.

ee_select_neighbors.hip

• 1

##### Share on other sites

Thank you very much eetu, this is what I was looking for.

##### Share on other sites

The file provided by eetu work very good but if I use expression `primneighbours(opinputpath(".", 0), \$PR, 2)`

in AttribCreate-Sop it is very slow for big mesh. Is there other way to find neighbour primitives for every primitive in mesh?

Thank you very much!!

##### Share on other sites

attached is a vex based solution which should be much faster...

hth.

petz

get_neighbours.hip

• 7
• 1

##### Share on other sites

Hey that's nice!

I didn't even know all these hedge_ functions existed! They are not even listed in the vex functions help page - seems they are buried in the page on half-edges..

##### Share on other sites

Thank you very much petz!

You are right, VEX solution is a lot faster as expression. On my computer it is around 5000 times faster !

##### Share on other sites

There is also an in between solution if you are not so much into writing vex code. It is about 50% slower than the vex written function but it is easier to set up.

get_neighbours-otherMethod.hipnc

##### Share on other sites

I think Group Edge Depth is the fastest method of all. You have to convert from points to primitives first though which shouldn't be bad.

• 1

##### Share on other sites

you can also use a connectivity sop,
delete everything but the primitive you are after.
and then have another delete sop that looks at that attribute and delete everything that does not have the same value.

## Create an account

Register a new account