Hi,
In my head this should be simple, but I am not able to solve.
I am trying to do something like in the "COPY" command. It is multiple, but if I hit enter the command stops.
In this exemple:
(defun c:SWW ()
(while
(princ "\nSelect objects or Exit")
...my routine here...
);while
);defun
If I hit enter at the "Select objects or Exit" promp, the command will stops. Is that possible or I am dreaming?
Thanks!
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Perhaps...
(defun c:SWW ()
(while (and (princ "\nSelect objects or Exit")
(setq ss (ssget))
)
...my routine here...
);while
);defun
Henrique
Hi,
the (ssget) function will pause (like any standard command select objects) until you finish your selection or exist with escape.
(if (setq ss (ssget))
(progn
; your code continues here (if the selection not fails)
)
)
so there is no need for (while) function
Moshe
Perfect Henrique!
That was exctly what I was looking for.
Thanks also to Moshe-A for your answer, but I realy needed the WHILE to repeat the command.
Thanks to all!
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
@msarqui wrote:
....
I am trying to do something like in the "COPY" command. It is multiple, but if ... enter at the "Select objects or Exit" promp, the command will stops. Is that possible or I am dreaming?
....
If you want to do something like that and also allow options additional to just selecting something or exiting, one way to go about it is illustrated in two routines of mine at the Cadalyst CAD Tips website, one to put Text labels on things and Break them around the Text, and another to do the same but Mask behind the Text rather than Break the labeled objects. They both make use of the ERRNO System Variable. They spell out available options [in this case mostly about the characteristics of the Text labels, but also including a one-at-a-time internal Undo] in an (initget) function, and use (entsel) in a (while) loop for the User to select an object, offering those options with <exit> as the default. A (cond) function looks at what the User did in response -- selected something, typed an allowable option, or hit Enter/space. If the User hit Enter/space, (getvar 'errno) returns 52, and the (cond) function sees that and sets a variable that stops the (while) loop to exit the routine. [The same approach could be used without the additional-options possibility, but that could be considered overkill in that simpler situation, compared to the suggestions already made here.]
@scot-65 wrote:
Another method:
Select object first, check if OK at the while, my routine here, select another object, end the while.
(setq s (entsel "Select an object: "))
(while s
...my routine here...
(setq s (entsel "Select another object: "))
);while
Nice one Scot
I used your solution for another routine.
Thanks!