How to select all block references within a closed polyline

Trying to select all the blocks within a closed polyline. I would like to be able to select the polyline, and have it return all the blocks contained within that polyline. Select the red polyline, yellow objects should be selected, blue objects should not.

Dynamo_Question

One approach is to use the closed poly to make a patch surface and then use ‘does intersect’ node with block insertion converted to points and use a bool filter to select the blocks. Welcome to the community!

2 Likes

Thank you Kirk!

I got it to work by the routine below. However, it’s very slow since it has to look through every block in the drawing.

I’ve been having trouble creating a patch surface from the closed polyline.

Thanks for your help!

The ContainmentTest is very slow. Maybe there are other solutions in external packages, but you can speed up this approach as well.

Create a BoundingBox of the Polygon and see if the Block position X and Y values are greater than the Bounding Box MinPoint and smaller than the MaxPoint. Comparing numeric values is much faster than a ContainmentTest.

The Blocks that are inside the BoundingBox can be processed in the ContainmentTest function, and because you already skipped lots of the Blocks, the remaining will process much faster.

2 Likes

Thank you both, I was able to get it to work much faster by figuring out the Surface.ByPatch.

My solution below in case anyone else needs it someday.

2 Likes