I'm trying to write a lisp where user selects the circles in the drawing and the radius and center coordinates of these circles are written in a file. So far I have done this much. (I actually tried to merge 2 different lisps but I'm a newbie and don't have much experience with AutoLisps )
(defun c:XY (/ fp p)
(setq fp (open (strcat (getvar "dwgprefix")(vl-filename-base (getvar "dwgname")) ".pnt") "w"))
(setq nbs 0)
(while (setq PickObject (nentsel "\n Pick a Circle to Get Entity Data: "))
(progn
(if
(/= nil (osnap (cadr PickObject) "_cen"))
(progn
(setq CenterPoint (osnap (cadr PickObject) "_cen"))
(setq NeaPoint (osnap (cadr PickObject) "_nea"))
(setq Radius (distance CenterPoint NeaPoint))
(setq Diameter (* 2 Radius))
(write-line (strcat "\n Radius: " (rtos Radius 2 2) " | " "Diameter: " (rtos Diameter 2 2) " | " "CenterPoint: " (rtos CenterPoint 2) ) fp)
)
(princ "\n Error! Picked Object don't has Radius! Try Again!")
)
)
(princ "\n Error! Null Selection!")
)
(close fp)
(princ))
{code}
)
To get Radius I used this lips but I don't know how to get center coordinates of the circle from this lisp.
{code}
(defun c:gcad (/ PickObject CenterPoint NeaPoint Radius Diameter);Get Circle Arc Data
;;; Written by Rogerio Zanini - 31.mar.2010
;;; Based in threat from (thanks to All):
;;; http://forums.augi.com/showthread.php?t=113352
(if (and
(princ "\n Show Radius and Diameter from Arcs (Lwpolyline and Polyline Included) and Circles...")
(setq PickObject (nentsel "\n Pick an Arc or Circle to Get Entity Data: "))
)
(progn
(if
(/= nil (osnap (cadr PickObject) "_cen"))
(progn
(setq CenterPoint (osnap (cadr PickObject) "_cen"))
(setq NeaPoint (osnap (cadr PickObject) "_nea"))
(setq Radius (distance CenterPoint NeaPoint))
(setq Diameter (* 2 Radius))
(princ (strcat "\n Radius: " (rtos Radius 2 2) " | " "Diameter: " (rtos Diameter 2 2)))
)
(princ "\n Error! Picked Object don't has Radius! Try Again!")
)
)
(princ "\n Error! Null Selection!")
)
(princ))
{code}