wow, ronjonp, u r fast
Here is how I would group the objects as sublists.
ur way is better. I still have some problems in applying the "mapcar" and "lambda". hard to understand...need to do more homework
Here is one using David's centroid\vertex distance method...
My way of calculating the centroid is much more complicated and much slower than urs. Do we get the same centroid by these two methods? Here's mine.
....
From my tests they return different results depending on the shape (square\rectangle same) other polygons different. My guess is the centroid function uses more points along the boundary.
You can shorten your routine above by using "vlax-get" since it will return the point and not a variant.
(defun centroid (ent /)
(command "_REGION" ent "")
(setq p1 (vlax-get (vlax-ename->vla-object (entlast)) 'centroid))
)
Enjoy