highlight a selection set

wjbzone

Usenet Archive
Joined
Feb 1, 2004
Messages
1
Reaction score
0
How can I highlight (and un-highlight) a selection set in autolisp. Thanks Bill
 
have a look at the "Redraw" function. You can use it to hilite and un-hilite an element. You'll probably have to loop through the selection set though.

If I remember right the following is true:

(redraw ename 4);hilites the element
(redraw ename 0);un-hilites the element
Assuming my recollections above are right, try the following (if they aren't right you'll have to go with the corrected numbers in the function call).

;to hilite the selection set:
(redraw_sset sset 4)
;to un-hilite the selection set:
(redraw_sset sset 0)

(defun redraw_sset(ent setting / ent cnt)
(setq cnt -1)
(repeat (sslength ent ctn)
(redraw (ssname ent (setq cnt (1+ cnt))) setting)
)
)
 
In addition to trying John's and rdi's, if interested in ActiveX methods you could get an ActiveX selset and use the "Highlight" method on it. Here's a sample of what I use. A simple call to regen or (vla-highlight ss :vlax-false) will clear the highlighting.

HTH,
Jeff

;| Create an ActiveX selection Set. May use selset filters. (c) Jeff Mishler Jan 2004
Usage:
Don't apply Filters: (setq ss (active_ss nil nil))
Apply Filters: (setq ss (active_ss '(0) '("LINE")))
The filter lists must comply with the standard ss filters, the first being the list of dxf codes '(0 8 2) and the second is the dxf value, ie: '("LINE") or '("LINE,ARC" "0,TEST"), etc. |; (defun active_ss (code val / ss) (if (vl-catch-all-apply 'vla-item (list (vla-get-selectionsets *doc*) "activex_ss")) (progn (setq ss (vla-item (vla-get-selectionsets *doc*) "activex_ss")) (vla-clear ss) ) (setq ss (vla-add (vla-get-selectionsets *doc*) "activex_ss")) ) (if code (progn (setq code (vlax-safearray-fill (vlax-make-safearray vlax-vbinteger (cons 0 (- (length code) 1)) ) code ) val (vlax-safearray-fill (vlax-make-safearray vlax-vbvariant (cons 0 (- (length val) 1)) ) val ) ) (vlax-invoke-method ss 'selectonscreen code val) ) (vla-selectonscreen ss) ) (vla-highlight ss :vlax-true) ss )
 
Egads. I just realized I posted the wrong code. This was a cut/paste from another file, except I got the interim file instead of the final one. My apologies to anyone who tried to use the first one. Here's the correct, working, one:

;| Create an ActiveX selection Set. May use selset filters. (c) Jeff Mishler Jan 2004
Usage:
Don't apply Filters: (setq ss (active_ss nil nil))
Apply Filters: (setq ss (active_ss '(0) '("LINE")))
The filter lists must comply with the standard ss filters, the first being the list of dxf codes '(0 8 2) and the second is the dxf value, ie: '("LINE") or '("LINE,ARC" "0,TEST"), etc. |; (defun active_ss (code val / ss) (vl-catch-all-apply 'vla-add (list (vla-get-selectionsets *doc*) "activex_ss")) (setq ss (vla-item (vla-get-selectionsets *doc*) "activex_ss")) (vla-clear ss) (if code (progn (setq code (vlax-safearray-fill (vlax-make-safearray vlax-vbinteger (cons 0 (- (length code) 1)) ) code ) val (vlax-safearray-fill (vlax-make-safearray vlax-vbvariant (cons 0 (- (length val) 1)) ) val ) ) (vlax-invoke-method ss 'selectonscreen code val) ) (vla-selectonscreen ss) ) (vla-highlight ss :vlax-true) ss )

Jeff
 
or test this code

(setq ss (ssget))
(setq e (ssname ss 0))
(prompt "\n1=Show entity,2=Hide entity,3=Highlight entity,4=Unhighlight entity") (setq opt (fix (getreal "\nENTER NEW VALUE: ")))
(redraw e opt)
 

Latest threads

Back
Top