Layer List

Scott

Usenet Archive
Joined
Feb 29, 2000
Messages
607
Reaction score
0
Hi

I was wondering how I could go about obtaining a list off all the layer names in the current drawing? I will then need to assign this list to a single variable for Vlisp.

Thanks
 
Scott said:
Hi

I was wondering how I could go about obtaining a list off all the layer names in the current drawing? I will then need to assign this list to a single variable for Vlisp.

Here is one way:

(defun laylist ( / llist lnlist)
(setq llist (tblnext "layer" t))
(while llist
(setq lnlist (cons (cdr (assoc 2 llist)) lnlist))
(setq llist (tblnext "layer"))
)
(acad_strlsort lnlist)
)

Then -> (setq a (laylist))
 
Frank Oquendo said:
How about this:

(defun laylist (/ llist lnlist)
(while (setq llist (tblnext "layer"))
(setq lnlist (cons (cdr (assoc 2 llist)) lnlist))
)
)

Yes, you are correct. That does work.
......until you run it the second time.
 
A minor change:

(defun laylist (/ llist lnlist)
(while (setq llist (tblnext "layer" (not llist)))
(setq lnlist (cons (cdr (assoc 2 llist)) lnlist))
)
)
 
Wow! Thank you everybody for your help with this!

Jason Piercey said:
Try this. Works for any table, not just the layer table.

; author - Puckett
; - string, valid table name
; returns each item name from
(defun table (s / d r)
(while (setq d (tblnext s (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
)
(reverse r)
)

Examples:
(setq myListOfLayerNames (table "layer"))

(setq myListOfBlockNames (table "block"))

(setq myListOfViewNames (table "view"))

etc....

R.K. McSwain said:
Yes, you are correct. That does work.
.....until you run it the second time.
 
Try this. Works for any table, not just the layer table.

; author - Puckett
; - string, valid table name
; returns each item name from
(defun table (s / d r)
(while (setq d (tblnext s (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
)
(reverse r)
)

Examples:
(setq myListOfLayerNames (table "layer"))

(setq myListOfBlockNames (table "block"))

(setq myListOfViewNames (table "view"))

etc....
 
R.K. McSwain said:
Yes, you are correct. That does work.
.....until you run it the second time.

Did that limitation exist in the original routine?
 
Mark Propst said:
compare frank's post to the one that said it didn't work

I'm lost. :(

Frank *is* the one who posted the version that didn't work (after the first time it was run).
 
Back
Top