Author Topic: Layer Counter, No Xref Layers  (Read 2784 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Layer Counter, No Xref Layers
« on: March 05, 2004, 03:09:46 PM »
I have the following code to tell me how many layers reside in the current drawing. How do I OMIT XREF layers?

Code: [Select]

(setq table-list3 nil)
(setq lay3 (tblnext "layer" T))
(while lay3
(setq lname3 (cdr (assoc 2 lay3))
lclr3 (cdr (assoc 62 lay3))
)
(if (/= lname3 "0")
(setq laytype3 (cdr (assoc 6 lay3))
table-list3 (cons lname3 table-list3)
)
)
(setq lay3 (tblnext "layer"))
)
(setq table-list3
(reverse table-list3)
cnt3 0
)
(setq bad-list3 nil)
(setq res-str3 (strcat "This drawing has "
(itoa (length table-list3))
" layers in it\n"
)
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Layer Counter, No Xref Layers
« Reply #1 on: March 05, 2004, 04:00:22 PM »
You could try this.

Code: [Select]
(defun c:laycount ()
  (setq table-list3 nil)
  (setq lay3 (tblnext "layer" t))
  (while lay3
    (setq lname3 (cdr (assoc 2 lay3))
 lclr3 (cdr (assoc 62 lay3))
    )
    (if (null (or (= lname3 "0") (wcmatch lname3 "*|*")))
      (setq laytype3 (cdr (assoc 6 lay3))
   table-list3 (cons lname3 table-list3)
      )
    )
    (setq lay3 (tblnext "layer"))
  )
  (setq table-list3
(reverse table-list3)
cnt3 0
  )
  (setq bad-list3 nil)
  (setq res-str3 (strcat "\nThis drawing has "
(itoa (length table-list3))
" layers in it"
)
  )
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.