I'm wondering if anyone knows a way to detect of there are objects currently selected using Autolisp, visual lisp or even VBA. I would like to be able to do something using that as a conditional, so that (assuming the hypothetical variable isSelected is an on/off indicator of whether or not something is selected) I can code something like this:
(if (isSelected) (...) )
any help would be appreciated.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@Anonymous wrote:I'm wondering if anyone knows a way to detect of there are objects currently selected . I would like to be able to do something using that as a conditional, so that (assuming the hypothetical variable isSelected is an on/off indicator of whether or not something is selected) I can code something like this:
(if (isSelected) (...) )....
You can use the implied-selection option in the selection-method argument in (ssget):
(if (ssget "_I")
(...)
)
Sweet. Two weeks of googling with no results and all it takes is one post on the forums...
@Anonymous wrote:Sweet. Two weeks of googling with no results and all it takes is one post on the forums...
You can use the same approach to go even further than just determining whether there's anything pre-selected. For instance, you can find out whether there are any Line entities among a pre-selection:
(if (ssget "_I" '((0 . "LINE")))
(...)
); if
And you can do things like put them into a variable directly in the process if there are, but ask the User to pick some if there are not:
(if (not (setq liness (ssget "_I" '((0 . "LINE")))))
(progn ; then -- ask User to select
(prompt "\nTo [do something with] Lines.")
(setq liness (ssget '((0 . "LINE"))))
); progn
); if
(...do something with liness...)
Can't find what you're looking for? Ask the community or share your knowledge.