View Full Version : selecting an object
18th Dec 2004, 12:16 am
I am using
(setq myobject(ssget "_:S"))
to get a single object from the user. However, if the user clicks on empty
space the function simply continues and produces an error later. How can I get my function to wait until the user actually chooses a valid object. Like the "break" function for example. If you don't select an item, you are asked to select an object again.
Thanks for the help
18th Dec 2004, 12:48 am
You need to put your selection function within a while loop that tests to see if an object has been selected. Here's an example:
(setq obj nil)
(while (= obj nil)
(setq obj (entsel "\nSelect object: "))
Now it's quite some time since I did any serious LISPing and so there may be a more modern way to go about this but it does work. The user will continue to be prompted until an object is selected.
If you only want a single object, entsel is simpler than ssget because no selection set is required.
18th Dec 2004, 03:07 am
I still prefer (sssget) over (entsel)
(while (or (not ss)
(> (sslength ss) 1))
(princ "\nSelect 1 <filtered> object: ")
(setq ss (ssget ))) ;include filter list
(setq obj (ssname ss 0))
18th Dec 2004, 10:12 am
One more example with ENTSEL and filter with MEMBER function.
(setq obj(car(entsel "\nSelect text object or Esc to Quit ")))
(member(cdr(assoc 0(entget obj))) '("TEXT" "MTEXT" "ATTRIBUTE"))
); end and
); end while
18th Dec 2004, 11:55 am
Ah, there you see - I knew there would be a number of different opinions on this and I'm sure that Fuccaro will add another when he sees this.
David, why do you prefer ssget over entget. It seems more complicated?
18th Dec 2004, 01:38 pm
Always you can add extras but a simple SSGET works fine for me...
18th Dec 2004, 02:36 pm
I've always prefered (ssget) due to fact that you can use Last/Prev/ etc whereas (entsel) is pretty limited. Also (ssget) filtering is a lot is a lot cleaner (IMO ) than after selection entity testing. -David
18th Dec 2004, 03:12 pm
In most cases I too prefer SSGET. However sometimes from aesthetic reasons I use ENTSEL. It is not pleasant to me that at a choice of one object with an option " _:S " the choice by a frame enabled and an inscription ' Select objects:'. 8)
18th Dec 2004, 06:08 pm
Fantomas, you and I are on the same wavelength, Entget is certainly more elegant for selecting a single object. Irrespective of other considerations it is just more beautiful :roll: and anyone who has done any programming/scripting should look for beauty in their code - don't you think?
Certainly it is potentially confusing for the user to be asked to "select objects" when only one object is required.
19th Dec 2004, 06:06 pm
Yes I too such opinion. Unfortunately AutoLISP not always allows to make all beautifully. For example DCL is a parody on HTML, it is necessary to use ObjectDCL and others libruaries for example DosLib. But it limits representation of such programs at forums because demands from the user of loading additional *.arx files. :(
21st Dec 2004, 05:45 pm
Thanks for the help, don't know why I didn't think of that.
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.