Tharwat Posted June 10, 2016 Share Posted June 10, 2016 Thanks, once again Tharwat! Always learning something new from you bit by bit. You are very welcome. Would like to see your modification on the codes specially the part we were talking about. Furthermore you can build a filter in the last ssget function to select only the objects that are invisible. Difficult? I don't think so. Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 10, 2016 Share Posted June 10, 2016 Sure, when I get back home I'll post some codes! Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 10, 2016 Share Posted June 10, 2016 So here is it, with non-VLA approach on the visibility part: ; Original code by Lee Mac (setq acadobject (vlax-get-Acad-Object)) (setq acdoc (vla-get-activedocument acadobject)) (setq VisReact:reactorid "VisReact:reactor") (defun c:VisReactOn nil (VisReact:toggle VisReact:reactorid) (vlr-miscellaneous-reactor VisReact:reactorid '((:vlr-pickfirstmodified . VisReact:callback))) ; reactor type: miscellaneous, reactor event: pickfirstmodified (princ "\nReactor enabled.") (princ) ) (defun c:VisReactOff nil (VisReact:toggle VisReact:reactorid) (princ "\nReactor disabled.") (princ) ) (defun VisReact:toggle ( key ) (foreach rtr (cdar (vlr-reactors :vlr-miscellaneous-reactor)) (if (= key (vlr-data rtr)) (vlr-remove rtr)) ) ) (defun VisReact:callback ( rtr arg ) (if (and (setq SS (cadr (ssgetfirst))) (setq sel (ssget "_X" (list (cons 60 0)(cons 410 (getvar 'ctab))))) ) (progn (repeat (setq i (sslength sel)) (setq ent (ssname sel (setq i (1- i)))) (cond ((ssmemb ent SS) (PutEntInvisible ent nil) ) (T (PutEntInvisible ent T) ) ) );repeat (vla-Regen acdoc :vlax-true) ) (progn (repeat (setq i (sslength sel)) ; iterate trought selection (setq ent (ssname sel (setq i (1- i)))) ; current entity (PutEntInvisible ent nil) );repeat (vla-Regen acdoc :vlax-true) ) ) (princ) ) ; end of reactor callback (vl-load-com) (princ) (defun PutEntInvisible ( ent vs / i k) (setq k (if vs 1 0)) (entmod (append (entget ent) (list (cons 60 k)))) (entupd ent) ) I like this ssmemb function, and it answers OP's main question I mean by this example: (although he got the code he needed) (defun C:test ( / SSL SSX SSL-Inverse ent) (if (and (setq SSL (ssget "_:L")) (setq SSX (ssget "_X")) (setq SSL-Inverse (ssadd)) ) (progn (repeat (setq i (sslength SSX)) (setq ent (ssname SSX (setq i (1- i)))) (cond ((ssmemb ent SSL) nil ) (T (ssadd ent SSL-Inverse) ) ) ) (princ "\nSelected the opposite objects!") (sssetfirst nil SSL-Inverse) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 10, 2016 Share Posted June 10, 2016 (cond ((ssmemb ent SS) (PutEntInvisible ent nil) ) (T (PutEntInvisible ent T) ) ) This is enough: (PutEntInvisible ent (if (ssmemb ent SS) nil t)) Regarding to function vla-regen that you use it two times just move it out of the function if codes and use it once. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 10, 2016 Share Posted June 10, 2016 This is enough: (PutEntInvisible ent (if (ssmemb ent SS) nil t)) Or even:(PutEntInvisible ent (not (ssmemb ent SS))) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 10, 2016 Share Posted June 10, 2016 Or even:(PutEntInvisible ent (not (ssmemb ent SS))) Yes, even better. Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 10, 2016 Share Posted June 10, 2016 Regarding to function vla-regen that you use it two times just move it out of the function if codes and use it once. Woops! Alright, I was just afraid to mess up something as I'm dealing with a reactor. Thanks for the correction, seems more like we're playing a game "lets shorten the code" Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 10, 2016 Share Posted June 10, 2016 seems more like we're playing a game "lets shorten the code" I believe with less codes performance is better . Quote Link to comment Share on other sites More sharing options...
halam Posted June 13, 2016 Author Share Posted June 13, 2016 I am trying to work out a way to change the display ground to show that you are in a other visibility state. Is there a way to store the variabele 'currGraphicsWinModelBackgrndColor' properly global in order that the other functions (later) can use this value? In my example descriped above the inverse command should switch to the old setting with the black background. The code beneith i found in the help files but i have no clue how i can use it in a decent matter.. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq preferences (vla-get-Preferences acadObj)) ;; Retrieve the current GraphicsWinModelBackgrndColor value (setq currGraphicsWinModelBackgrndColor (vlax-variant-change-type (vla-get-GraphicsWinModelBackgrndColor (vla-get-Display preferences)) vlax-vbLong)) (alert (strcat "The current value for GraphicsWinModelBackgrndColor is " (itoa (vlax-variant-value currGraphicsWinModelBackgrndColor)))) ;; Change the value for GraphicsWinModelBackgrndColor (vla-put-GraphicsWinModelBackgrndColor ACADPref (vlax-make-variant 127 19)) (setq newValue (vlax-variant-change-type (vla-get-GraphicsWinModelBackgrndColor ACADPref) vlax-vbLong)) (alert (strcat "The new value for GraphicsWinModelBackgrndColor is " (itoa (vlax-variant-value newValue)))) ;; Reset GraphicsWinModelBackgrndColor to its original value (vla-put-GraphicsWinModelBackgrndColor ACADPref currGraphicsWinModelBackgrndColor) (alert (strcat "The GraphicsWinModelBackgrndColor value is reset to " (itoa (vlax-variant-value currGraphicsWinModelBackgrndColor)))) Quote Link to comment Share on other sites More sharing options...
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.