Hi.
I wonder if someone have some code for handling this "Select objects or <select all>:"?
Thanks in advance.
\Freddy
Two ways you can do that
<Not thoroughly tested>
single selection
(defun c:test (/ options objects) (setq options (entsel "\nSelect object or <select all>:")) (if (= options nil) (setq objects (ssget "_X")) ) (sssetfirst nil objects)(princ) )
This one for ssget <multiple selection>
(defun c:test (/ options objects) (prompt "\nSelect objects or <select all>:") (setq objects (ssget)) (if (= objects nil) (setq objects (ssget "_X")) ) (sssetfirst nil objects)(princ) )
Thanks.
It is something like the second suggestion, but that leave me with:
Select objects or <select all>:
Select objects:
It had been nice to handle it with only the first line like it is in the TRIM and EXTEND command. Is that possible?
\Freddy
.
Play around with NOMUTT variable
(defun c:test ( / objects) (prompt "\nSelect Object or <select all>:)") (setvar "nomutt" 1) (setq objects (ssget)) (setvar "nomutt" 0) (if (not objects) (setq objects (ssget "_X")) ) (sssetfirst nil objects) )
Retry a reply, in Rich text mode, IE8, XP:
One common way to provide a default answer is implemented in a substiture for the getdist or getreal, like:
; GET_D, with Default value, D. AusCadd.com
(Defun Get_D (d s / ans ) (setq d (if (numberp d) d 1.0)
ans (getdist (strcat " " s " < " (rtos d 2 4) " > ")))
(if ans ans d) )
; get real
(DeFun get_r (d ps / ans ) (
(setq d (if (and d (numberp d)) d 0)
ps (if (str_p ps) ps "\n Enter Number: ")
ans (getreal (strcat " " ps " < " (rtos d 2 4) " > ")))
(if ans ans d))
Do not know how that text insertion into this Reply will go, so an attached is ttried. The text, and others, at Auscadd.com, Free Subroutines.
For your application:
(setq oldlth (getvar "userr1"))
(setq lth (get_d oldlth)) ; mod'd
(if(= lth nil)(setq lth oldlth))
(setvar "userr1" lth)
Normally, the routine would set the defualt value upon loading, and offer a user change upon each call, or upon loading if the values seldom changed.
(setq val (cond ((getdist (strcat "\nEnter distance" (if val (strcat " <" (rtos val) ">: ") ": ") )))(val)) )