PDA

View Full Version : Finding the Center Point of a Polyline ?


stephen.coff
2007-07-16, 02:01 PM
Guys,
How can I find the center of a closed polyline shape drawn, as I want to place text there ?

Stephen

CADmium
2007-07-16, 02:55 PM
a simple routine to try .. saves the Centerpoint to he sysvar "LASTPOINT" an creates a circle ..

(defun c:PLCENTER (/ PL RE P)
(if(setq PL(car(entsel "\nSELECT PL:")))
(progn
(command "_undo" "_m")
(command "_region" PL "")
(if(and(setq RE(vlax-ename->vla-object (entlast)))
(=(strcase(vla-get-objectname RE)) "ACDBREGION")
(setq P (vla-get-centroid RE))
(setq P(vlax-safearray->list(vlax-variant-value P)))
)
(setvar "LASTPOINT" P)
)
(command "_undo" "_b")
)
)
(if P (command "_circle" P 5))
)

stephen.coff
2007-07-17, 01:58 AM
Thomas,
Your on fire, reply after reply, thanks heaps. I am actually wanting to use it with the area thread as set the location for the text. I will have a play and see how it goes.

Thanks again

Stephen