Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TimeGuardian on March 08, 2022, 09:19:40 AM
Title: Selecting and fltering inside an area
Post by: TimeGuardian on March 08, 2022, 09:19:40 AM
My problem is simple, i have many rectangles of the same size with objects inside them and for each rectangle i would like to select specific objects inside it and count. In the example image below, the objects to be selected are the red circles.
(https://i.imgur.com/vCNWBB1.png)
However there is the issue when the object is in multiple rectangles but i only want to count it once. In the example image below the point used to decide in which rectangle the object is, is the center of the circle.
(https://i.imgur.com/TUBGGdD.png)
If i only select whats completely inside the rectangle i wont be able to count the objects inside multiple rectangles but if i select everything even if its only partially inside i will count the same object multiple times.
Title: Re: Selecting and fltering inside an area
Post by: kirby on March 08, 2022, 05:38:13 PM
You could use the centroid of the various shapes to test if inside the boundary. Centroid is simple calc for circles obtuse polygons. More difficult for polylines (convert to Region then use vl-get-centroid, or use old school MassProp, or solve by geometry). If your shapes are blocks whose insertion point is at the centroid, then the problem is really simply.
However, will still need to resolve how to handle the condition where a centroid falls exactly on a boundary.
Title: Re: Selecting and fltering inside an area
Post by: BIGAL on March 09, 2022, 04:20:39 AM
What does the method (ssget "WP" listofco-ords return