highlight a selection set

Discussion in 'AutoCAD' started by wjbzone, Feb 1, 2004.

  1. wjbzone

    wjbzone Guest

    How can I highlight (and un-highlight) a selection set in autolisp.
    Thanks
    Bill
     
    wjbzone, Feb 1, 2004
    #1
  2. wjbzone

    John Uhden Guest

    You might try (sssetfirst nil ss) and then (sssetfirst).
     
    John Uhden, Feb 1, 2004
    #2
  3. wjbzone

    rdi Guest

    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)
    )
    )
     
    rdi, Feb 1, 2004
    #3
  4. wjbzone

    rdi Guest

    Never heard of that one.
     
    rdi, Feb 1, 2004
    #4
  5. wjbzone

    Jeff Mishler Guest

    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
    )
     
    Jeff Mishler, Feb 1, 2004
    #5
  6. wjbzone

    Jeff Mishler Guest

    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
     
    Jeff Mishler, Feb 2, 2004
    #6
  7. wjbzone

    Adesu Guest

    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)
     
    Adesu, Jan 27, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.