Jump to content

(getint) or (getpoint)


moha_aga

Recommended Posts

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,

Link to comment
Share on other sites

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

Link to comment
Share on other sites

; (get_pt_or_int "\nPick a point [Exit] <int>: " "\nSpecify int [Exit] <point>: ")
(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 [Exit]: "))

 

But you'd need to process it, it will return strings from keyboard inputs, such as: "123".

Link to comment
Share on other sites

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,

 

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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