samifox Posted December 14, 2013 Posted December 14, 2013 Hi im exploring the (polar) function so i made a loop on the background of a radian scheme. the problem is that i want to enter a lisp expression and see what happening on the scheme but i get "cant reenter lisp error" exampel Command: PLR Enter a factor : Command : (* pi 3) Can't reenter LISP. (defun C:PLR () (setq cen '(20.9463 13.5021 0.0)) (while (setq n (getstring T "\nEnter a factor :")) (setq n (atof n)) (polar cen n 50) (command "line" cen (polar cen n 50) "") ( ) ) ) see attachment Thanks Shay PLR.dwg Quote
jdiala Posted December 14, 2013 Posted December 14, 2013 (defun C:PLR (/ cen) (setq cen '(20.9463 13.5021 0.0)) (while (setq n (getangle "\nEnter angle:")) (command "line" cen (polar cen n 50) "") )(princ) ) Quote
samifox Posted December 15, 2013 Author Posted December 15, 2013 (defun C:PLR (/ cen) (setq cen '(20.9463 13.5021 0.0)) (while (setq n (getangle "\nEnter angle:")) (command "line" cen (polar cen n 50) "") )(princ) ) please read my massage as well Quote
satishrajdev Posted December 16, 2013 Posted December 16, 2013 Samifox..... I tried both code.... on your uploaded file, I didnt get error which you have talked about. following code of jdiala's working properly than to yours.... (defun C:PLR (/ cen [color=red]n[/color]) (setq cen '(20.9463 13.5021 0.0)) (while (setq n (getangle "\nEnter angle:")) (command "line" cen (polar cen n 50) "") )(princ) ) Quote
samifox Posted December 16, 2013 Author Posted December 16, 2013 try to type expression like (* pi 2)when you asked to type a factor Quote
satishrajdev Posted December 16, 2013 Posted December 16, 2013 Getangle don't accept (* pi 2) so I tried your code which is given below..... I didnt get any error... see attached image too When I type (* pi 2) it drawn red line..... (defun C:PLR (/ cen n) (setq cen '(20.9463 13.5021 0.0)) (while (= (setq n (getstring T "\nEnter a factor :")) nil) (command "line" cen (polar cen (atof n) 50) "") ) (princ) ) Quote
pBe Posted December 16, 2013 Posted December 16, 2013 _$ (setq n (getstring T "\nEnter a factor :")) "(* pi 1.5)" _$ (atof n) [b]0.0 [/b] Should be at 270.... Quote
pBe Posted December 16, 2013 Posted December 16, 2013 try to type expression like (* pi 2)when you asked to type a factor Me thinks you should settle with just typing the factor number then construct the expression (* pi n) before passing the argument to polar function. Quote
MSasu Posted December 16, 2013 Posted December 16, 2013 Samifox, please pay attention that you cannot input an AutoLISP statement to the prompt of a function from GET* family; excerpt from help: The user cannot enter another AutoLISP expression as the response to a getangle request. Quote
samifox Posted December 16, 2013 Author Posted December 16, 2013 Me thinks you should settle with just typing the factor number then construct the expression (* pi n) before passing the argument to polar function.[/QUOTe] I DIDNT GET YOU Samifox, please pay attention that you cannot input an AutoLISP statement to the prompt of a function from GET* family; excerpt from help: so can i use expresions from command line or not? Quote
marko_ribar Posted December 16, 2013 Posted December 16, 2013 I DIDNT GET YOUso can i use expresions from command line or not? I think pBe meant this : (defun C:PLR (/ cen n) (setq cen '(20.9463 13.5021 0.0)) (while (= (setq n (getreal "\nEnter a factor (* pi n) - n: ")) "") (command "line" cen (polar cen (* pi n) 50) "") ) (princ) ) Quote
MSasu Posted December 17, 2013 Posted December 17, 2013 so can i use expresions from command line or not? Unfortunately you cannot use AutoLISP expressions at command line when input to the prompt of one of GET* family functions or of commands called from AutoLISP. You can do this for the prompts of built-in commands, as long those where not called from AutoLISP. Quote
MSasu Posted December 17, 2013 Posted December 17, 2013 Some examples: Wrong: Command: (getreal "\nInput real number: ")Input real number: (* 2 3.0) Command: (command "_CIRCLE" pause pause)CIRCLE Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: (list 0.0 0.0) Specify radius of circle or [Diameter]: (* 2 3.0) Correct: Command: _CIRCLESpecify center point for circle or [3P/2P/Ttr (tan tan radius)]: (list 0.0 0.0) Specify radius of circle or [Diameter]: (* 2 3.0) Quote
pBe Posted December 17, 2013 Posted December 17, 2013 I think pBe meant this : .... (while (= (setq n (getreal "\nEnter a factor (* pi n) - n: ")) "") (command "line" cen (polar cen (* pi n) 50) "") ) .. Thank you Marko, now if samifoxs' intention is to always use (* pi number) then: (defun C:PLR ( / cen n ang) (setq cen '(20.9463 13.5021 0.0)) (while (setq n (getreal "\nEnter a factor (* pi n) - n: ")) (setq ang (* pi n)) (while (> ang (* pi 2)) (setq ang (- ang (* pi 2))) ) (command "line" "_non" cen "_non" (polar cen ang 50) "" ) (princ (Strcat "(* pi " (rtos n) ") : " (angtos ang 0 2))) ) (princ) ) but if want to input a different expression every time then you can use something like this (defun C:PLR (/ cen n ang) (setq cen '(20.9463 13.5021 0.0)) (while [color="blue"](/= (setq n (getstring T "\nEnter lisp expression :")) "")[/color] [color="blue"](setq _n n ang (eval (read n)) )[/color] (while (> ang (* pi 2)) (setq ang (- ang (* pi 2))) ) (command "line" "_non" cen "_non" (polar cen ang 50) "" ) [color="blue"] (princ (Strcat _n " : " (angtos ang 0 2)))[/color] ) (princ) ) **NOTE: no error trap [its for the OP to add]** (validity of input that is) HTH Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.