LISP Subfunction to get "center" inside closed polyline (not centroid)

LISP Subfunction to get "center" inside closed polyline (not centroid)

Anonymous
Not applicable
3,512 Views
3 Replies
Message 1 of 4

LISP Subfunction to get "center" inside closed polyline (not centroid)

Anonymous
Not applicable

Hello there, Im looking for a script or some help to find a script that finds the center point inside a given closed polyline. I have been doing some research and now I know I need to get "the center of the largest rectangle lying inside the polyline", or "the point inside the polyline that is most distant to it's vertexes/sides". I need it to place labels inside polylines that represents parcels.

I have tryed drawing lines between all vertexes, exclude those that intersect the polyline and drawing circles in the center of the rest; then growing their radius and deleting those intersecting the polyline until only one is left, but that doesn't solve all my problems, and sometimes fails...

 

Does anyone know what is the better approach to solve this? Or remembers any forum or page where people talked about getting this result (not simple centroids)

 

thanks

0 Likes
Accepted solutions (1)
3,513 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant
Accepted solution

Hi,

 

You can have a look at this reply.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4

Anonymous
Not applicable

❤️

thaks!!!

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

I had this underway before @_gile 's Reply, so I'm posting it even though it's not quite as precise.  The file name stands for "Text in the Middle of Polyline Open Area."

 

It uses a similar notion, in a brute-force way -- Offset inward as far as is possible, and the middle of the largest open area will be where the smallest viable result lies.  You could get closer to the precision in his routine by reducing the size of the incrementing of Offset distance, and perhaps by using the Centroid of the last successful result instead of the middle of its bounding box, but for the stated purpose I imagine it's close enough.

 

It includes putting in a Text label  ["HERE" -- you will, of course, supply your own content, or have it ask the User for it, or something] in the middle, with height related to the size of the boundary, and using whatever the current Text Style is [in my trials, STANDARD without fixed height].  You can specify the Style and a particular height instead, but if you use a Style with a fixed  height, remove  the height element in the Text command.

 

Accounting for the possibility that Offsetting more irregular shapes can give more than one resulting Polyline was the trickiest part.  Lightly tested, but it seems to work.

Kent Cooper, AIA
0 Likes