CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 1517
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

 

HelpCAD discussion

 
CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedSS Get and Lisp Question

 Post Reply Post Reply
Author
mfkozlow View Drop Down
Groupie
Groupie


Joined: 14.Jul.2014
Location: United States
Using: AutoCAD Electrical 2014
Status: Offline
Points: 25
Direct Link To This Post Topic: SS Get and Lisp Question
    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.

Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,313 seconds.