DuanJinHui Posted April 14, 2017 Posted April 14, 2017 Hi all How Highlighting a Selection Set ? Quote
ziele_o2k Posted April 14, 2017 Posted April 14, 2017 (setq ss (ssget)) (repeat (setq in (sslength ss)) (vla-highlight (vlax-ename->vla-object (ssname ss (setq in (1- in)))) :vlax-true) ) Quote
ziele_o2k Posted April 14, 2017 Posted April 14, 2017 (redraw <entity> 3) Much much much faster Quote
Tharwat Posted April 14, 2017 Posted April 14, 2017 Much much much faster Hint: Always try to use vanilla (plain AutoLISP) before you think about Vlisp. This is my way at least. Quote
DuanJinHui Posted April 14, 2017 Author Posted April 14, 2017 (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. Quote
DuanJinHui Posted April 14, 2017 Author Posted April 14, 2017 (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. Quote
Tharwat Posted April 14, 2017 Posted April 14, 2017 I know "redraw" function . But this can only Highlighting object (ent) ,not for a Selection Set. Please let me know when you find one. Quote
Grrr Posted April 14, 2017 Posted April 14, 2017 (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. Quote
Tharwat Posted April 14, 2017 Posted April 14, 2017 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). Quote
ziele_o2k Posted April 14, 2017 Posted April 14, 2017 (...)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) ) Quote
Grrr Posted April 14, 2017 Posted April 14, 2017 (edited) 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 April 14, 2017 by Grrr Quote
Tharwat Posted April 15, 2017 Posted April 15, 2017 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: Quote
Grrr Posted April 15, 2017 Posted April 15, 2017 Must write opposite program for amateur Cad users if they tried this program by any bad luck. :lol: Its not that bad, just close (& save) the current drawing, and never use that code again. 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. Quote
Jef! Posted April 25, 2017 Posted April 25, 2017 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) ) Quote
Tharwat Posted April 25, 2017 Posted April 25, 2017 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. Quote
Jef! Posted April 25, 2017 Posted April 25, 2017 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! Quote
Recommended Posts
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.