Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Layer List

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
426 Views, 13 Replies

Layer List

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
13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

"Scott" wrote
> 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))
Message 3 of 14
Anonymous
in reply to: Anonymous

R.K. McSwain wrote:

> (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)
> )

How about this:

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

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
Message 4 of 14
Anonymous
in reply to: Anonymous

"Frank Oquendo" wrote
> 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.
Message 5 of 14
Anonymous
in reply to: Anonymous

A minor change:

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


--
R. Robert Bell, MCSE
www.AcadX.com


"R.K. McSwain" wrote in message
news:5056DC539A91CBC27BF82D8B0EB49A19@in.WebX.maYIadrTaRb...
| "Frank Oquendo" wrote
| > 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.
Message 6 of 14
Anonymous
in reply to: Anonymous

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....


--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


"R.K. McSwain" wrote in message
news:5056DC539A91CBC27BF82D8B0EB49A19@in.WebX.maYIadrTaRb...
> Yes, you are correct. That does work.
> .....until you run it the second time.
Message 7 of 14
Anonymous
in reply to: Anonymous

Wow! Thank you everybody for your help with this!

Jason Piercey wrote in message
news:DC278797B52B333D9A6A42872C61B2B9@in.WebX.maYIadrTaRb...
> 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....
>
>
> --
>
> -Jason
> Member of the Autodesk Discussion Forum Moderator Program
>
>
> "R.K. McSwain" wrote in message
> news:5056DC539A91CBC27BF82D8B0EB49A19@in.WebX.maYIadrTaRb...
> > Yes, you are correct. That does work.
> > .....until you run it the second time.
>
>
Message 8 of 14
Anonymous
in reply to: Anonymous

R.K. McSwain wrote:

> Yes, you are correct. That does work.
> .....until you run it the second time.

Did that limitation exist in the original routine?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
Message 9 of 14
Anonymous
in reply to: Anonymous

"Frank Oquendo" wrote
> Did that limitation exist in the original routine?
>

No, why?
Message 10 of 14
Anonymous
in reply to: Anonymous

compare frank's post to the one that said it didn't work

"R.K. McSwain" wrote in message
news:891EC8995505FFB2CD3B3EA5E4113C59@in.WebX.maYIadrTaRb...
> "Frank Oquendo" wrote
> > Did that limitation exist in the original routine?
> >
>
> No, why?
>
Message 11 of 14
Anonymous
in reply to: Anonymous

"Mark Propst" wrote in message news:02C39EDFE8D229214EC5BA082C41A3C1@in.WebX.maYIadrTaRb...
> 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).
Message 12 of 14
Anonymous
in reply to: Anonymous

my bad, I was seeing your post in his reply! ...I'm the one whos lost!
:-)

"R.K. McSwain" wrote in message
news:A087133500F08DB2390FCC03AA008F1D@in.WebX.maYIadrTaRb...
> "Mark Propst" wrote in message
news:02C39EDFE8D229214EC5BA082C41A3C1@in.WebX.maYIadrTaRb...
> > 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).
Message 13 of 14
Anonymous
in reply to: Anonymous

I want to create an autolisp routine to list all layers in a drawing and
modify objects in some of the layers from this list. How can I do this.

Ashit
Message 14 of 14
Anonymous
in reply to: Anonymous

Ashit

(setq layers (vla-get-layers (vla-get-activedocument
(vlax-get-acad-object))))

will return a collection of all the layers in the current drawing.
Can you eloborate on what exactly

> modify objects in some of the layers from this list.

means?

Steve


"Ashit Goyal" wrote in message
news:232818F3236784B9CE8321B8D8AA1B36@in.WebX.maYIadrTaRb...
> I want to create an autolisp routine to list all layers in a drawing and
> modify objects in some of the layers from this list. How can I do this.
>
> Ashit
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost