Display full version of the post: running a function in autocad

Frank98
18.02.2017, 10:53
Hello, i have tried to save the code bellow as a lisp, the i loaeded it and in the vommand line i wrote the name of the lisp file and nohing happened,if you could help me understand how  run function in outocad ,i have attache my cad menu in the photo bellowthanks(defun curve () (prompt "Routine to draw the basic sinuous curve ") (terpri) (setq start (getpoint "Pick the start point ")) (terpri) (setq rl (getreal "Enter the minimum radius ")) (terpri) (setq r2 (getreal "Enter the maximum radius ")) (terpri) (setq s (getreal "Enter the incremental step ")) (terpri) (setq tau (getreal "Enter the value of tau ")) (terpri)    (while (< rl (- r2 s))     (setq fl (* (/ pi 4) (sin (* pi (/ (log (/ rl r2)) (log tau))))))     (setq x 1 (+ (* rl (cos fl)) (car start)))     (setq yl (+ (* rl (sin fl)) (cadr start)))     (setq rl (+ rl s))     (setq f2 (* (/ pi 4) (sin (* pi (/ (log (I r 1 r2)) (log tau))))))     (setq x2 (+ (* rl (cos f2)) (car start)))     (setq y2 (+ (* rl (sin f2)) (cadr start)))      (command "line"        (setq p (list xl y1))        (setq p (list x2 y2))        ""       )      ))

Vladimir Michl
18.02.2017, 16:55

The name of the LISP function is "curve" so you can invoke it by typing the "(curve)" command - note the parenthesis. If you want to make it a custom command (invoked by name), defun it as "C:Curve" - i.e.: (defun C:Curve ( ....