+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 29
  1. #1
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    699

    Default Inverse selectionset on a "x" statement

    Registered forum members do not see this ad.

    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
    Last edited by halam; 7th Jun 2016 at 11:02 pm.
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

  2. #2
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,474

    Default

    Hi, personally I would go this way:
    Code:
    (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)
    			)
    		)	
    	)
    )

  3. #3
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    699

    Default

    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'.. ;-)


    Code:
    ..
    ..
    (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


    Code:
     
     
      (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
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

  4. #4
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,474

    Default

    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?

  5. #5
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    699

    Default

    Hi
    I made a short video.
    I hope this helps to give you the idea.
    https://youtu.be/bjJNXLwbXbo
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

  6. #6
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,474

    Default

    Made all four functions (with prefix of test), have a play:
    Code:
    ; 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.

  7. #7
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    699

    Default

    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/suppo...F0C53-htm.html
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

  8. #8
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    You can shorten the above codes and functions with two functions as follows:

    Code:
    (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:
    Code:
    (PutEverythingInvisible ss t) 
    ;; t   = Make objects Invisible. 
    ;; nil = Make objects Visible.
    And to reverse visibility of objects:
    Code:
    (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)))))
        )
      )

  9. #9
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,474

    Default

    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.

  10. #10
    Super Member halam's Avatar
    Using
    AutoCAD 2017
    Join Date
    Jul 2015
    Posts
    699

    Default

    Registered forum members do not see this ad.

    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.
    https://youtu.be/y9-ZU8g5E5o
    Modelling is done with two hands, 2d & 3d. Let it work together..
    https://twitter.com/halammerts

Similar Threads

  1. Replies: 6
    Last Post: 25th Apr 2018, 09:04 pm
  2. Area Statement Under Layer "Acquired No. & Area" to the csv
    By sanju2323 in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 25th Feb 2015, 10:17 am
  3. Replies: 21
    Last Post: 14th Jul 2014, 07:04 am
  4. "Where db..." statement issue
    By Autodesk in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 16th Jun 2011, 04:30 pm
  5. LISP "IF" statement ending with error
    By brawleyman in forum AutoLISP, Visual LISP & DCL
    Replies: 37
    Last Post: 16th Jul 2009, 11:21 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts