I've created a selection set by manually selecting objects. now what i want to do is highlight those objects later on in the session. so using previous to highlight the selection set is not an option. is there a way to have a selection set that is stored in the drawing highlighted on demand? i want to do this with LISP since this step will be used in conjunction with another step and i only know LISP.
thanks in advance,
Larry
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Solved by Lee_Mac. Go to Solution.
; select the objects (setq p (ssget)) (do_something_else_here) ; select the selection set "p" (sssetfirst nil p)
Is this what you mean?
I think you're talking about redraw. Check that function out.
i thought i had it right, but it didn't work for me when i tested it. now i'm thinking it's because of the selection set name. here's what i wrote, trying to specify a selection set name that can be recalled later. maybe you can see the error:
(DEFUN C:SSBM()
(SETVAR "CMDECHO" 0)
(SETQ WTD(UKWORD 1 "Create Highlight" "Selection set: (Create or Highlight)" WTD)) ;custom command similar to GETKWORD
(IF(= WTD "Create")(PROGN
(SETQ BMSS(UANS "Name for selection set" NIL NIL))
(SETQ BMSS(SSGET))
(SSSETFIRST NIL BMSS)
)
(PROGN
(SETQ BMSS(UANS "Name of selection set to highlight" BMSS NIL))
(SSSETFIRST NIL BMSS)
)
)
(PRINC)
)
@bdsmls wrote:
i thought i had it right, but it didn't work for me when i tested it. now i'm thinking it's because of the selection set name. here's what i wrote, trying to specify a selection set name that can be recalled later. maybe you can see the error:
....
(IF(= WTD "Create")
(PROGN ; then
(SETQ BMSS(UANS "Name for selection set" NIL NIL))
(SETQ BMSS(SSGET))
(SSSETFIRST NIL BMSS)
)
(PROGN ; else
(SETQ BMSS(UANS "Name of selection set to highlight" BMSS NIL))
(SSSETFIRST NIL BMSS)
)
....
It's hard to say without seeing what the (UANS) function does. I'm hoping that will make it clear why there are two settings of BMSS in the 'then' part, but only one in the 'else' part. But in either case, provided something was actually selected, the (sssetfirst) function ought to highlight/grip it/them.
it did grip them, but only during the "create" part of the routine. when i tried to rehighlight the set it didn't work. that's why my original question was only how to highlight an old selection set. sorry i didn't clarify about the UANS, its basically just GETSTRING except it requires a value. the reason for two BMSS was i was trying to name the selection set before selecting so there is a name to identify the set for rehighlighting later
Here is a very simple version of what I believe you are looking to achieve:
(defun c:ssbm ( / sel var ) (initget "Create Highlight") (if (= "Create" (getkword "\nChoose [Create/Highlight] <Highlight>: ")) (if (and (setq var (ssbm:newname "\nName for selection set: ")) (setq sel (ssget)) ) (set (read var) sel) ) (if (setq var (ssbm:getname "\nName of selection set to highlight: ")) (sssetfirst nil (eval (read var))) ) ) (princ) ) (defun ssbm:newname ( msg ) (ssbm:getstringif msg '(lambda ( x ) (not (boundp (read x)))) "\nName invalid or already in use.") ) (defun ssbm:getname ( msg ) (ssbm:getstringif msg '(lambda ( x ) (= 'pickset (type (eval (read x))))) "\nSelection set not found.") ) (defun ssbm:getstringif ( msg prd els / str ) (while (not (or (= "" (setq str (getstring msg))) ((eval prd) str))) (princ els) ) (if (/= "" str) str) ) (princ)
If (UANS) is like (getstring), it appears that in your 'then' part you're setting BMSS to a string first, and then to a selection set. In your 'else' part you're setting it only to a string, which will overwrite any selection set previously stored in that variable name, and which (sssetfirst) will not be able to highlight.
that worked great for highlighting existing selection sets, but it doesn't highlight the set when it's created
I'm sure you could've worked that one out
(defun c:ssbm ( / sel var ) (initget "Create Highlight") (if (= "Create" (getkword "\nChoose [Create/Highlight] <Highlight>: ")) (if (and (setq var (ssbm:newname "\nName for selection set: ")) (setq sel (ssget)) ) (sssetfirst nil (set (read var) sel)) ) (if (setq var (ssbm:getname "\nName of selection set to highlight: ")) (sssetfirst nil (eval (read var))) ) ) (princ) ) (defun ssbm:newname ( msg ) (ssbm:getstringif msg '(lambda ( x ) (not (boundp (read x)))) "\nName invalid or already in use.") ) (defun ssbm:getname ( msg ) (ssbm:getstringif msg '(lambda ( x ) (= 'pickset (type (eval (read x))))) "\nSelection set not found.") ) (defun ssbm:getstringif ( msg prd els / str ) (while (not (or (= "" (setq str (getstring msg))) ((eval prd) str))) (princ els) ) (if (/= "" str) str) ) (princ)
to take this one more step, seeing as how if enough selection sets are created it could become difficult to remember their names, is there a way to list the names of the sets for easy viewing?
Larry
to take this one more step, seeing as how if enough selection sets are created it could become difficult to remember their names, is there a way to list the names of the sets for easy viewing?
Try something like this:
(defun c:ssbm ( / sel var ) (initget "Create Highlight") (if (or (null ssbm:selsets) (= "Create" (getkword "\nChoose [Create/Highlight] <Highlight>: "))) (if (and (setq var (ssbm:newname "\nName for selection set: ")) (setq sel (ssget)) (setq ssbm:selsets (cons var ssbm:selsets)) ) (sssetfirst nil (set (read var) sel)) ) (progn (initget "?") (while (= "?" (setq var (ssbm:getname "\nName of selection set to highlight [?]: "))) (foreach x (acad_strlsort ssbm:selsets) (print x)) ) (if var (sssetfirst nil (eval (read var)))) ) ) (princ) ) (defun ssbm:newname ( msg ) (ssbm:getstringif msg '(lambda ( x ) (not (boundp (read x)))) "\nName invalid or already in use.") ) (defun ssbm:getname ( msg ) (ssbm:getstringif msg '(lambda ( x ) (or (= "?" x) (= 'pickset (type (eval (read x)))))) "\nSelection set not found.") ) (defun ssbm:getstringif ( msg prd els / str ) (while (not (or (= "" (setq str (getstring msg))) ((eval prd) str))) (princ els) ) (if (/= "" str) str) ) (princ)