Search code examples
autocadpolar-coordinatesautolisp

Stuck in AutoLISP using polar


Well I'm sort of stuck and don't know what to do. I need to write program using AutoLisp, which would draw five-pointed star. I don't have any knowledge in AutoLisp programming, but managed to write this and it seems to me, correct, but AutoCAD won't draw anything. Maybe someone could help? (long numbers are angles in radian) Code:

(defun C:Figura3 ()
  (setq pl (getpoint "\nStart coordinate: ")) ;;; Coordinates of circle center
  (setq aukst (getint "\nRadius: "))
  ;;; Coordinates of vertices
  (setq p2 (polar p1 1.570796327 aukst)) ;;; 90 (degrees) 
  (setq p3 (polar p1 2.827433388 aukst)) ;;; 162
  (setq p4 (polar p1 4.08407045 aukst)) ;;; 234
  (setq p5 (polar p1 5.340707511 aukst)) ;;; 306
  (setq p6 (polar p1 0.3141592654 aukst)) ;;; 18
  ;;; Drawing
  (command "color" "white")
  (command "lweight" 0.35)
  (command "circle" p1 aukst)
  (command "line" p2 p4 p6 p3 p5 p2 "")
)

Solution

  • You've defined the command 'Figura3', however you'll need to actually call it as well for it to do any work. Type Figura3 at the command prompt after you load/type your function definition and AutoCAD will run your function like you'd expect.

    There's also an issue with your first point though. It's defined as 'pl' (lowercase 'L') and later referenced as 'p1'.