mfkozlow Posted October 21, 2014 Posted October 21, 2014 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. Quote
BlackBox Posted October 21, 2014 Posted October 21, 2014 Written quickly; these may be of help: (vl-load-com) (defun _GetLayersOn (/ layersOn) (vlax-for oLayer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)) ) (if (= :vlax-true (vla-get-layeron oLayer)) (setq layersOn (cons (vla-get-name oLayer) layersOn)) ) ) (reverse layersOn) ) (defun _List->WcString (lst) (if (< 1 (length lst)) (vl-string-right-trim "," (apply 'strcat (mapcar (function (lambda (x) (strcat x ","))) lst ) ) ) lst ) ) Example: (if (setq ss (ssget "_x" [color="red"](list '[/color](0 . "INSERT") [color="red"]'[/color](2 . "SYSTEM_SP_Q") [color="red"](cons 8 (_List->WcString (_GetLayersOn)))[/color] [color="red"])[/color] ) ) ;;<-- do something useful ) Cheers Quote
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.