; This program creates a polygon in autocad programmatically
; By accepting number of sides and side length
; Created by Jytra Engineering Services (
www.jytra.com)
(defun c:drawpoly()
(setq sides (getint "\n Enter number of sides: "))
(setq size (getreal "\n Enter side of the polygon : "))
(setq length1 (rtos size))
(setq angle1 (/ 360 sides))
(setq newpt (getpoint "\n Pick the starting point:"))
(setq count 0)
(while (< count sides)
(setq angl (* count angle1))
(setq ang (rtos angl))
(setq tmp (command "line" newpt (strcat "@" length1 "<" ang) ""))
(setq tmp (entget (entlast)))
(setq newpt (cdr (assoc 11 tmp)))
(setq count (1+ count))
)
)