moha_aga 发表于 2022-7-5 15:34:55

(getint) or (getpoint)

I need lisp to choose (getint) or (getpoint)
(setq txt(getint))
(setq pt(getpoint))
If I have txt I do not need pt
and if I have pt I do not need txt
so I need to choose beteen pt and txt on one process.
regards,

Aftertouch 发表于 2022-7-5 15:54:56

Something like this?

(cond((and txt pt)        (princ "Both are present. Error?"))(txt        (setq pt (getpoint "\nSelect point")))(pt        (setq txt (getint "\nWhats the text?")))(t        (princ "Neither are present...")))

Tharwat 发表于 2022-7-5 15:55:49

Hi,
 
Try this:

(or (setq no (getint "\nEnter an integer:"))   (setq pt (getpoint "\nSpecify a point :"))   )

Grrr 发表于 2022-7-5 16:07:29

; (get_pt_or_int "\nPick a point : " "\nSpecify int : ")(defun get_pt_or_int ( mp mi ) (cond    ( (progn (initget "Exit") (getpoint mp)) )   ( (progn (initget "Exit") (getint mi)) )   ( (get_pt_or_int mp mi) ) ); cond); defun
 
Or -
 

(progn (initget 128 "Exit") (getpoint "\nSpecify input : "))
 
But you'd need to process it, it will return strings from keyboard inputs, such as: "123".

asos2000 发表于 2022-7-5 16:20:25

May be this

...

Stefan BMR 发表于 2022-7-5 16:25:20

 
maybe this

(while (progn   (initget 128)   (setq var (getpoint "\nInsertion point or Number: ")) ) (print var))Command:Insertion point or Number:(-2.43958 704.87 0.0)Insertion point or Number:"aaa"Insertion point or Number:"123"Insertion point or Number:As you can see, you can pick a point or you can type something. The output is a list (a point) or a string. You only need to check the input validity.

asos2000 发表于 2022-7-5 16:43:56

Give this a try

(if   (and   (setq e (car (nentsel "\nSelect Level: ")))   (setq en (entget e))   (setq typ(cdr (assoc 0 en)))   )   (progn   (cond( (eq typ "MTEXT")(setq ent (cdr (assoc 0 en))) )( (eq typ "TEXT")(setq ent (cdr (assoc 0 en))) )( (eq typ "POINT")(setq ent (cdr (assoc 0 en))) )        ); cond   ) )
 
And change DXF number to what ever you want
 

(assoc 0 en)
页: [1]
查看完整版本: (getint) or (getpoint)