Print Page | Close Window

SS Get and Lisp Question

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DXF formats, Design Review, AutoCAD web, Drive, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=10738
Printed Date: 05.Sep.2026 at 04:16


Topic: SS Get and Lisp Question
Posted By: mfkozlow
Subject: SS Get and Lisp Question
Date Posted: 17.Oct.2014 at 16:18
Hell everyone.

I currently have the following lisp file:

(defun C:get_att()

  (if (setq ss (ssget "_F" '((7 2.5) (13.5 2.5)) '((0 . "INSERT"))))
(progn 
(setq en (ssname ss 0))                                                  

  (setq enlist(entget en))                                          ;- Get the DXF group codes

  (setq blkType(cdr(assoc 0 enlist)))                 ;- Save the type of entity

  (if (= blkType "INSERT")                                          ;- If the entity type is an Insert entity

   (progn

    (if(= (cdr(assoc 66 enlist)) 1)    ;- See if the attribute flag equals one (if so, attributes follow)

    (progn

      (setq en2(entnext en))                                    ;- Get the next sub-entity

      (setq enlist2(entget en2))                           ;- Get the DXF group codes
   
      (setq enlist3(cdr(assoc 1 enlist2)))

      (while (/= (cdr(assoc 0 enlist2)) "SEQEND")  ;- Start the while loop and keep                                                                                                                   ;-  looping until SEQEND is found.

        (princ "\n ")                                                 ;-Print a new line

        (princ enlist2)                                               ;- Print the attribute DXF group codes

        (setq en2(entnext en2))                             ;- Get the next sub-entity

        (setq enlist2(entget en2))                      ;- Get the DXF group codes

      )

     )

    )  ;- Close the if group code 66 = 1 statement

   )

  )   ;- Close the if block type = "ATTRIB" statement

)

)   ;- Close the if an Entity is selected statement

)
The lisp above gathers many useful pieces of information from the block that it intersects. I use this information later on in variables.

At the beginning of the lisp the ss get function is utilized. Instead of the way it is working right now, I would like to use the following code for the ss get function.
(defun c:thaw ( / a ex)
(setq ex nil)
(while (setq a (tblnext "LAYER" (null a)))
          (if (and (or (> (cdr (assoc 70 a)) 0)
                   (minusp (cdr (assoc 62 a)))
               )
               (not (wcmatch (cdr (assoc 2 a)) "*|*"))
              )
            (setq ex (cons (strcat "," (cdr (assoc 2 a)) ) ex))
          )
        ) 
;;;    For selection and processing    ;;;
    ;;;(setq ss  (ssget "_X"
    ;;;         (append
    ;;;           (list (cons 410 (getvar 'ctab)))
    ;;;             (if ex
    ;;;               (list
    ;;;                 '(-4 . "<NOT")
    ;;;                 (cons 8 (strcat (apply 'strcat ex)))
    ;;;                 '(-4 . "NOT>")
    ;;;               )
    ;;;               '(8 . "*")
    ;;;             )
    ;;;           )
    ;;;         )
    ;;;      )
    ;;; 
(textscr) 
;;;    Demo purposes    ;;;
  (princ "\nExcluded Layers from selection:")
  (foreach itm (reverse ex)
    (princ (strcat "\n" (substr itm 2))))
;;;            ;;;
  (princ)
  )
The lisp above scans for all the layers that are off and returns the names of these layers in a list format.

So in conclusion, I would like the ss get function to scan for all the layers that are turned off and exclude those layers from my selection. Using that list I would like to use this exact function
(if (setq ss (ssget "_X" '((2 . "SYSTEM_SP_Q"))))

instead of using this
(if (setq ss (ssget "_F" '((7 2.5) (13.5 2.5)) '((0 . "INSERT"))))


So to clear things up. First the lisp file will scan for the layers that are turned off. Once it knows this list I want it to exclude all the layers in that list (the ones that are off) and use it along with this function:
(if (setq ss (ssget "_X" '((2 . "SYSTEM_SP_Q"))))


Thank you in advance for anyone who takes the time to read all of this.




Print Page | Close Window