Jump to content

How Highlighting a Selection Set ?


DuanJinHui

Recommended Posts

(setq ss (ssget))
(repeat (setq in (sslength ss))
 (vla-highlight (vlax-ename->vla-object (ssname ss (setq in (1- in)))) :vlax-true)
)

Link to comment
Share on other sites

(setq ss (ssget))
(repeat (setq in (sslength ss))
 (vla-highlight (vlax-ename->vla-object (ssname ss (setq in (1- in)))) :vlax-true)
)

 

Thank you Sir .I will test.

Link to comment
Share on other sites

(redraw <entity> 3)

 

Hi Mr Tharwat . Thank you for reply .

 

I know "redraw" function . But this can only Highlighting object (ent) ,not for a Selection Set.

Link to comment
Share on other sites

(redraw <entity> 3)

 

I was wondering before where the redraw function is used... now I will know, thanks! :)

 

 

BTW (sssetfirst nil SS) may work, but it should be avoided for a large selection sets - because its really slow.

Link to comment
Share on other sites

I was wondering before where the redraw function is used... now I will know, thanks! :)

My pleasure. :)

 

You can explore this function more since it has more actions to do other than just highlighting an entity.

 

BTW (sssetfirst nil SS) may work, but it should be avoided for a large selection sets - because its really slow.

There is a difference between these two functions (redraw & sssetfirst).

Link to comment
Share on other sites

(...)But this can only Highlighting object (ent) ,not for a Selection Set.

 

(setq ss (ssget))
(repeat (setq in (sslength ss))
 (redraw (ssname ss (setq in (1- in))) 3)
)

Link to comment
Share on other sites

You can explore this function more since it has more actions to do other than just highlighting an entity.

 

Yeah, I had to research from the help reference on the internet, the only info from the help on my acad 2015 about redraw is:

"Refreshes the display in the current viewport."

 

The reference from here reveals alot more info about that function:

1 -- Show entity

2 -- Hide entity (blank it out)

3 -- Highlight entity

4 -- Unhighlight entity

 

There is a difference between these two functions (redraw & sssetfirst).

 

Yes I know, the thing is that I was always using sssetfirst to grip my selection - for the only reason to see what I've selected.

After some testing - indeed iterating over the SS with (redraw 3) looks/feels the fastest way, and to remove the highlighting - iterate all over again with (redraw 4).

Regen would also remove the highlights, but I try to avoid sssetfirst and regen, when working on a large drawings (they seem to slowdown the code's performance).

And I was even trying to regen only the active viewport...

 

How to be evil 101 :

(defun HideAll:CB ( rtr args / e )
 (and (equal args '("REGEN")) (setq e (entnext)) (while e (redraw e 2) (setq e (entnext e))) )
); defun HideAll:CB
(HideAll:CB nil '("REGEN"))
(foreach r (cdar (vlr-reactors :vlr-command-reactor)) (if (= "HideAll" (vlr-data r)) (vlr-remove r)))
(vlr-command-reactor "HideAll" '((:vlr-commandEnded . HideAll:CB)))

Edited by Grrr
Link to comment
Share on other sites

How to be evil 101 :

(defun HideAll:CB ( rtr args / e )
 (and (equal args '("REGEN")) (setq e (entnext)) (while e (redraw e 2) (setq e (entnext e))) )
); defun HideAll:CB
(HideAll:CB nil '("REGEN"))
(foreach r (cdar (vlr-reactors :vlr-command-reactor)) (if (= "HideAll" (vlr-data r)) (vlr-remove r)))
(vlr-command-reactor "HideAll" '((:vlr-commandEnded . HideAll:CB)))

 

Must write opposite program for amateur Cad users if they tried this program by any bad luck. :lol: :lol:

Link to comment
Share on other sites

Must write opposite program for amateur Cad users if they tried this program by any bad luck. :lol: :lol:

 

Its not that bad, just close (& save) the current drawing, and never use that code again. :lol:

 

Also I'm using this while working, its much faster to process only the active viewport - instead of the REGEN command :

(defun RegenActiveViewport nil 
 (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport) 
)

 

And its temporary wayaround while that reactor is running.

Link to comment
Share on other sites

  • 2 weeks later...
I know "redraw" function . But this can only Highlighting object (ent) ,not for a Selection Set.

 

 

Please let me know when you find one.

 

 

Highlighting a selection set is very easy... use sssetfirst :)

(defun c:highlightselsel ( / selset)
(setq selset (ssget))
(sssetfirst nil selset)
)

Link to comment
Share on other sites

Highlighting a selection set is very easy... use sssetfirst :)

 

Hi,

You can do instead of the variable selset and replace it with the ssget function immediately in the sssetfirst statement, what's importantly with this function is that it won't throw any error if ssget returned nil.

Link to comment
Share on other sites

Hi,

You can do instead of the variable selset and replace it with the ssget function immediately in the sssetfirst statement, what's importantly with this function is that it won't throw any error if ssget returned nil.

 

I doubt the OP (or anyone else) would do that... my thougths for that conclusion are that

-Either the selection set is a result of functions using (ssget "X", (ssadd or (ssdel, and is already in a variable

-That selection set might need further processing, hence the need to have it in a var.

-Other than that, there's not much point of using (sssetfirst nil (ssget)), as it basically just complicate things to just "mimic" plain selecting things, that of course would still need some more complication to be sure that it wouldn't bomb if the user don't select anything. My 2 cents.

 

Cheers! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...