halam Posted June 7, 2016 Share Posted June 7, 2016 (edited) Hi all, Its me, back again.. Can somebody explain me how of inverse this selection can work? Lee Mac has some good explanations, but this one it can't find (setq ss1 (ssget "x" '((60 . 1)))) ; find any invisible objects the idea is to make a function to turn around the invisible / visible objects displayed ... I Kindly thank U http://www.lee-mac.com/selsetprocessing.html Edited June 7, 2016 by halam Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 7, 2016 Share Posted June 7, 2016 Hi, personally I would go this way: (if (and (setq SS-invis (ssget "_X" (list (cons 60 1)))) (setq SS-vis (ssget "_X" (list (cons 60 0)))) ) (initget 1 "visible invisible") (progn (setq ans (getkword "\nWhich selection to grip [visible/invisible] ?")) (cond ((= ans "visible") (sssetfirst nil SS-vis) ) ((= ans "invisible") (sssetfirst nil SS-invis) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
halam Posted June 7, 2016 Author Share Posted June 7, 2016 Thank you mister Grrr. That seems like a very logical sentence. Tried to plug it in directly but as expected it doesn't fit in right away How can i set the ss-invis / ss-vis to be my ss1 selectionset in the codes beneith? The idea is that you have two states. The invisible selectionset and the visible selectionset. If i have a routine to that would invert these states i could use it for some nice 3D modelling stuff... ;-) (sorry for my not very super good lisp skills, i appriciate any help in getting some good code very much..) I seem to have the code as parts but i cannot assemble these very nice. As i am 'a prutser'.. ;-) .. .. (your advice for the if) .. .. (if ss1 (progn (setq counter 0) (while (<= counter (- (sslength ss1) 1)) (setq en (ssname ss1 counter)) (setq look_for en) (setq LOOK_FOR_DXF (entget LOOK_FOR)) (setq LOOK_FOR_LAYER (cdr (assoc 8 LOOK_FOR_DXF))) (setq LAYER_LOCK_STATUS (CDR (ASSOC 70 (tblsearch "LAYER" LOOK_FOR_LAYER) ) ) ) (If (= LAYER_LOCK_STATUS 4) (progn (command "layer" "unlock" LOOK_FOR_LAYER "") ) ; End progn ) (setq LOOK_FOR_DXF (subst (cons 60 0) (assoc 60 LOOK_FOR_DXF) LOOK_FOR_DXF ) ) (entmod LOOK_FOR_DXF) (If (= LAYER_LOCK_STATUS 4) (progn (command "layer" "lock" LOOK_FOR_LAYER "") ) ; End progn ) (setq counter (+ counter 1)) ) ; End of while ) ; End progn ) ; End if (command "redrawall") (command "undo" "end") (princ) (princ) ) ; End defun, ; ..this code makes it visible.. (PRINC) this part to make selections invisible (setq ss1 (ssget)) ; Select objects (if ss1 ; If user has selected object(s) then (progn ; start this progn (setq counter 0) ; set-up a counter starting at 0 (while (<= counter (- (sslength ss1) 1)) ; While the counter is less than the total number of blocks in the SS1 selection set plus 1 (setq en (ssname ss1 counter)) ; find the entity name of the entity at counter number ? (setq look_FOR en) ; Set Look_FOR to the same as en (setq LOOK_FOR_DXF (entget LOOK_FOR)) ; Get the DXF list from the LOOK_For (setq LOOK_FOR_LAYER (cdr (assoc 8 LOOK_FOR_DXF))) ; Get the Layer information out of the DXF list of the entity (setq LAYER_LOCK_STATUS ; Find the layer status for the entities layer (CDR (ASSOC 70 (tblsearch "LAYER" LOOK_FOR_LAYER) ) ) ) (If (= LAYER_LOCK_STATUS 4) ; If the entities layer is locked then (progn ; do the following Progn (command "layer" "unlock" LOOK_FOR_LAYER "") ; Unlock the entities Layer ) ; End progn ) (setq LOOK_FOR_DXF (subst (cons 60 1) (assoc 60 LOOK_FOR_DXF) LOOK_FOR_DXF ) ) (setq tocon (cons 60 1)) (setq ToModify (append LOOK_FOR_DXF (list tocon))) (entmod ToModify) (If (= LAYER_LOCK_STATUS 4) (progn (command "layer" "lock" LOOK_FOR_LAYER "") ; Lock the LOOK_FOR_LAYER ) ; End progn ) (setq counter (+ counter 1)) ; add one to the counter for next item to process ) ; End of while ) ; End progn ) ; End if (command "undo" "end") (princ) ) ; End of defun Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 7, 2016 Share Posted June 7, 2016 Can you explain in simple words what are you trying to achieve? I see that you are locking/unlocking object's layers. Do you want to toggle the visibility of the objects and their layer's lock state? Quote Link to comment Share on other sites More sharing options...
halam Posted June 7, 2016 Author Share Posted June 7, 2016 Hi I made a short video. I hope this helps to give you the idea. Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 7, 2016 Share Posted June 7, 2016 Made all four functions (with prefix of test), have a play: ; test-isolate ; test-hide ; test-all-visible ; test-inverse ;isos (defun C:test-isolate ( / SSL SSX ) (vl-load-com) (setq acadobject (vlax-get-Acad-Object)) (setq acdoc (vla-get-activedocument acadobject)) (if (and (princ "\nSelect objects to isolate: ") (setq SSL (ssget "_:L")) (setq SSX (ssget "_X" )) );and (progn (PutEverythingInvisible SSX) (PutEverythingVisible SSL) (vla-Regen acdoc :vlax-true) );progn ) (princ) );defun ; ozbs (defun C:test-hide ( / SSL ) (vl-load-com) (setq acadobject (vlax-get-Acad-Object)) (setq acdoc (vla-get-activedocument acadobject)) (if (and (princ "\nSelect objects to hide: ") (setq SSL (ssget "_:L")) );and (progn (PutEverythingInvisible SSL) (vla-Regen acdoc :vlax-true) );progn ) (princ) );defun ;zb (defun C:test-all-visible ( / SSL SSX ) (vl-load-com) (setq acadobject (vlax-get-Acad-Object)) (setq acdoc (vla-get-activedocument acadobject)) (if (and (princ "\nSetting everything to visible! ") (setq SSX (ssget "_X" )) );and (progn (PutEverythingVisible SSX) (vla-Regen acdoc :vlax-true) );progn ) (princ) );defun (defun C:test-inverse ( / SSL SSX ) (vl-load-com) (setq acadobject (vlax-get-Acad-Object)) (setq acdoc (vla-get-activedocument acadobject)) (if (and (princ "\nInversing the visibility! ") (setq SSX (ssget "_X" )) );and (progn (ReverseVisibility SSX) (vla-Regen acdoc :vlax-true) );progn ) (princ) );defun (defun PutEverythingInvisible ( SS / ent enx vla-obj ) (repeat (setq i (sslength SS)) (setq ent (ssname SS (setq i (1- i)))) (setq enx (entget ent)) (setq vla-obj (vlax-ename->vla-object ent)) (if (and (vlax-property-available-p vla-obj "Visible") (= (vlax-get-property vla-obj 'Visible) :vlax-true)) (vla-put-Visible vla-obj :vlax-false) ) ) ) (defun PutEverythingVisible ( SS / ent enx vla-obj ) (repeat (setq i (sslength SS)) (setq ent (ssname SS (setq i (1- i)))) (setq enx (entget ent)) (setq vla-obj (vlax-ename->vla-object ent)) (if (and (vlax-property-available-p vla-obj "Visible") (= (vlax-get-property vla-obj 'Visible) :vlax-false)) (vla-put-Visible vla-obj :vlax-true) ) ) ) (defun ReverseVisibility ( SS / ent enx vla-obj ) (repeat (setq i (sslength SS)) (setq ent (ssname SS (setq i (1- i)))) (setq enx (entget ent)) (setq vla-obj (vlax-ename->vla-object ent)) (cond ((and (vlax-property-available-p vla-obj "Visible") (= (vlax-get-property vla-obj 'Visible) :vlax-false)) (vla-put-Visible vla-obj :vlax-true) ) ((and (vlax-property-available-p vla-obj "Visible") (= (vlax-get-property vla-obj 'Visible) :vlax-true)) (vla-put-Visible vla-obj :vlax-false) ) ) ) ) Btw I didn't put lock on selected objects's layers. Quote Link to comment Share on other sites More sharing options...
halam Posted June 8, 2016 Author Share Posted June 8, 2016 Woooww... this is super cool !!! What a great piece of work Grrr!. Will benefit during 3D modelling. So many thanks for your effort. The inverse function sure works!! Like a second model space made available Insipred from the bulb function in Revit, if you are in mood of Revit. https://knowledge.autodesk.com/support/revit-lt/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/RevitLT-DocumentPresent/files/GUID-B61C4920-0F8D-4243-9AD5-C75EC5BF0C53-htm.html Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 8, 2016 Share Posted June 8, 2016 You can shorten the above codes and functions with two functions as follows: (defun PutEverythingInvisible ( ss vs / i k) (setq k (if vs 1 0)) (repeat (setq i (sslength ss)) (entmod (append (entget (ssname ss (setq i (1- i)))) (list (cons 60 k)))) ) ) To test the above function out: (PutEverythingInvisible ss t) ;; t = Make objects Invisible. ;; nil = Make objects Visible. And to reverse visibility of objects: (defun ReverseVisibility ( ss / i e) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (entmod (append e (list (cons 60 (if (cdr (assoc 60 e)) 0 1))))) ) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 8, 2016 Share Posted June 8, 2016 Thanks for the advice Tharwat! Unfortunately I'm not list processing master as you are, more like a student of yours and Lee's I see that your example went back to plain lisp, as OP's original code, but I felt more comfortable using VLA. Quote Link to comment Share on other sites More sharing options...
halam Posted June 8, 2016 Author Share Posted June 8, 2016 Here is a short demo how i make use of it. It feels like a second modelspace. I use some dutch command shortcuts: - rew : rewind / inverse the display => test-inverse - ozbs : invisibly is this model view.. the beauty of it is that it will become visible after inversing it => test-hide - isos : isolate object selection => test-isolate happy youtubing this for AutoCAD comm. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 8, 2016 Share Posted June 8, 2016 Thank you Grrr. Personally I don not go with VLisp functions unless I am forced to, otherwise plain lisp is faster and works with old releases of AutoCAD while Vlisp can not. Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 8, 2016 Share Posted June 8, 2016 You're wellcome halam! Behind the skill of every code I do there are Tharwat and Lee Mac, so maybe add their names. Glad it helps. Quote Link to comment Share on other sites More sharing options...
halam Posted June 8, 2016 Author Share Posted June 8, 2016 Ok. I'm the follower ;-) Will monitor the code you supplied, see if it doesn't act strange with certain object definitions and for speed performance. I really don't care if it is vla or lisp. Maybe turn it into lisp if i want to work with Bricscad more later. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 8, 2016 Share Posted June 8, 2016 FWIW, you could forego the if statement when reversing the visibility: (defun reversevis ( s / i e ) (repeat (setq i (sslength s)) (entmod (append (setq e (entget (ssname s (setq i (1- i))))) (list (cons 60 (- 1 (cdr (assoc 60 e))))))) ) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 10, 2016 Share Posted June 10, 2016 By the way, I forgot to mention that earlier (before this thread was created) I was practicing/learning about reactors (using a template from Lee Mac - the original was "Properties Reactor"). And the result was close to the OP's request, so it might be handy: ; Original code by Lee Mac (setq reactname:reactorid "reactname:reactor") (defun c:reactnameon nil (reactname:toggle reactname:reactorid) (vlr-miscellaneous-reactor reactname:reactorid '((:vlr-pickfirstmodified . reactname:callback))) ; reactor type: miscellaneous, reactor event: pickfirstmodified (princ "\nReactor enabled.") (princ) ) (defun c:reactnameoff nil (reactname:toggle reactname:reactorid) (princ "\nReactor disabled.") (princ) ) (defun reactname:toggle ( key ) (foreach rtr (cdar (vlr-reactors :vlr-miscellaneous-reactor)) (if (= key (vlr-data rtr)) (vlr-remove rtr)) ) ) (defun reactname:callback ( rtr arg ) ; start of reactor callback (if (setq SS (cadr (ssgetfirst))) ; alternative method of implied selection (progn (setq sel (ssget "_X" (list (cons 410 (getvar 'ctab))))) (repeat (setq i (sslength sel)) ; iterate trought selection (setq ent (ssname sel (setq i (1- i)))) ; current entity (setq vla-obj (vlax-ename->vla-object ent)) (vla-put-Visible vla-obj :vlax-false) );repeat (repeat (setq i (sslength SS)) ; iterate trought selection (setq ent (ssname SS (setq i (1- i)))) ; current entity (setq vla-obj (vlax-ename->vla-object ent)) (vla-put-Visible vla-obj :vlax-true) ; (vla-delete vla-obj) );repeat ) (progn (setq sel (ssget "_X" (list (cons 410 (getvar 'ctab))))) (repeat (setq i (sslength sel)) ; iterate trought selection (setq ent (ssname sel (setq i (1- i)))) ; current entity (setq vla-obj (vlax-ename->vla-object ent)) (vla-put-Visible vla-obj :vlax-true) );repeat ) ) (princ) ) ; end of reactor callback (vl-load-com) (princ) Usage: reactnameon to turn on the reactor When a selection is made it is isolated reactnameoff to turn off the reactor. And yes: the slower VLA approach was used. Quote Link to comment Share on other sites More sharing options...
halam Posted June 10, 2016 Author Share Posted June 10, 2016 Does This mean a name is applied to a group, what is being names? I was thinking of giving a different background when objects are isolated. To see that You are in 'a different displaymode.. Like in revit all objects show different when the bulb is turned off. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 10, 2016 Share Posted June 10, 2016 Grrr, Read about this function SSMEMB Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 10, 2016 Share Posted June 10, 2016 Does This mean a name is applied to a group, what is being names? I was thinking of giving a different background when objects are isolated. To see that You are in 'a different displaymode.. Like in revit all objects show different when the bulb is turned off. No, I was refering to the reactor's name - you can change it like: "VisibilityReactorOn" instead of "ReactNameOn". As I've wrote in my post - it was a practice work. Grrr, Read about this function SSMEMB I've just read it.. but what I am missing - where I can apply SSMEMB in the code? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 10, 2016 Share Posted June 10, 2016 I've just read it.. but what I am missing - where I can apply SSMEMB in the code? In the following part: So there is no need for the second repeat function just adding the ssmemb function with if expression to check out if the selected object is a member, do this , otherwise this. (progn (setq sel (ssget "_X" (list (cons 410 (getvar 'ctab))))) (repeat (setq i (sslength sel)) ; iterate trought selection (setq ent (ssname sel (setq i (1- i)))) ; current entity (setq vla-obj (vlax-ename->vla-object ent)) (vla-put-Visible vla-obj :vlax-false) );repeat (repeat (setq i (sslength SS)) ; iterate trought selection (setq ent (ssname SS (setq i (1- i)))) ; current entity (setq vla-obj (vlax-ename->vla-object ent)) (vla-put-Visible vla-obj :vlax-true) ; (vla-delete vla-obj) );repeat ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 10, 2016 Share Posted June 10, 2016 Thanks, once again Tharwat! Always learning something new from you bit by bit. 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.