KRBeckman 发表于 2022-7-6 06:39:20

get* prompts to accept lisp ma

Hey Everybody,
 
Does anybody know how to make it so that prompts in our AutoLisp functions can accept lisp math functions?
 
Example:
 
If you start the line command, start the line from anywhere, move the mouse to the right a little and then type "(+ 10 15)" into the command prompt, it will create a 25 unit long line in the direction you moved the mouse in.
 
I have a few functions that I'd like to be able to use this capability, but when I try I get a "Can't reenter LISP." error.
 
Any help would be greatly appreciated.
 
Thanks!

MSasu 发表于 2022-7-6 07:31:34

I'm afraid that if you will check in gelp will notice that the functions from GET* family doesn't accept to use another AutoLISP expresion as input.

Stefan BMR 发表于 2022-7-6 08:09:07

 
You can use CAL command transparently:

Command:LINE Specify first point:Specify next point or :Specify next point or : 'cal >>>> Expression: 10+15Resuming LINE command.Specify next point or : 25Specify next point or :Command:You can also use CAL in lisp.
Next function is LINE command redefined. When you are prompted to pick next point, you can type a valid cal expression.
 

(defun C:TEST ( / p) (command "_line" "\\") (while   (progn   (initget 128)   (setq p (getpoint (getvar 'lastpoint) "\nNext point: "))   )   (if   (or       (listp p)       (setq p (cal p))       )   (command p)   )   ) (command "") (princ) )This is just a sample of using CAL.
CAL must be loaded, once per acad session: (arxload "geomcal.arx")
页: [1]
查看完整版本: get* prompts to accept lisp ma