Jump to content

Recommended Posts

Posted

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

Posted
(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)
)

Posted
(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 8)

Posted

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)
)

Posted

try to type expression like (* pi 2)when you asked to type a factor

Posted

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)
)

test.jpg

Posted

_$ (setq n (getstring T "\nEnter a factor :"))
"(* pi 1.5)"
_$ (atof n)
[b]0.0
[/b]

 

Should be at 270....

Posted
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.

Posted

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.
Posted
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?:unsure:

Posted
I DIDNT GET YOU

so can i use expresions from command line or not?:unsure:

 

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)
)

Posted
so can i use expresions from command line or not?:unsure:

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.

Posted

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: _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)

Posted
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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...