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

how to get layer description in lisp

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
2576 Views, 12 Replies

how to get layer description in lisp

Using autolisp - how can I obtain the layer description of a selected
drawing or xreference object?
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

what do you mean with layer description?
all layer names of a open drawing
all layer names of a selected xref


KDispoto wrote:

> Using autolisp - how can I obtain the layer description of a selected
> drawing or xreference object?
Message 3 of 13
Anonymous
in reply to: Anonymous

Ultimately I'd like to add the user defined layer "description" (as it
appears at the far right side of the layer properties dialog box) to the
LID.lsp routine below so that when I select a single object, whether it be a
base dwg object or an xreference object, the description would show in the
screen message.

(defun C:LID/)
(setvar "cmdecho" 0)
(setq AA (cdr (assoc 8
(entget (car (entsel "Select entity to set layer: "))))))


(setq EL (tblsearch "layer" AA))
(setq A2 (cdr(assoc 2 EL)))
(setq A62(cdr(assoc 62 EL)))

(setq LYRNM A2)
(setq LYRCLR (rtos A62 2 0))

(setq MSG (strcat "Layer: " LYRNM "\n" "\nLayer color: " LYRCLR))
(alert MSG)

)

"gert" wrote in message
news:5747887@discussion.autodesk.com...
what do you mean with layer description?
all layer names of a open drawing
all layer names of a selected xref


KDispoto wrote:

> Using autolisp - how can I obtain the layer description of a selected
> drawing or xreference object?
Message 4 of 13
Anonymous
in reply to: Anonymous

here's a few snippets of vlisp to get you going.

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(setq layObj (vla-item theLayers AA)) ;; the layer name you selected
(vla-put-description layObj "This is the layer description")

- the OF

"KDispoto" wrote in message
news:5747872@discussion.autodesk.com...
Ultimately I'd like to add the user defined layer "description" (as it
appears at the far right side of the layer properties dialog box) to the
LID.lsp routine below so that when I select a single object, whether it be a
base dwg object or an xreference object, the description would show in the
screen message.

(defun C:LID/)
(setvar "cmdecho" 0)
(setq AA (cdr (assoc 8
(entget (car (entsel "Select entity to set layer: "))))))


(setq EL (tblsearch "layer" AA))
(setq A2 (cdr(assoc 2 EL)))
(setq A62(cdr(assoc 62 EL)))

(setq LYRNM A2)
(setq LYRCLR (rtos A62 2 0))

(setq MSG (strcat "Layer: " LYRNM "\n" "\nLayer color: " LYRCLR))
(alert MSG)

)

"gert" wrote in message
news:5747887@discussion.autodesk.com...
what do you mean with layer description?
all layer names of a open drawing
all layer names of a selected xref


KDispoto wrote:

> Using autolisp - how can I obtain the layer description of a selected
> drawing or xreference object?
Message 5 of 13
Anonymous
in reply to: Anonymous

I appreciate the help - Being that I barely get by with lisp - I am not
familiar with vlisp (although I won't mind trying it here).

Using your code - what is the variable that contains the layer description
(vla-put-description layObj )?


"the Other Frank" wrote in message
news:5747942@discussion.autodesk.com...
here's a few snippets of vlisp to get you going.

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(setq layObj (vla-item theLayers AA)) ;; the layer name you selected
(vla-put-description layObj "This is the layer description")

- the OF

"KDispoto" wrote in message
news:5747872@discussion.autodesk.com...
Ultimately I'd like to add the user defined layer "description" (as it
appears at the far right side of the layer properties dialog box) to the
LID.lsp routine below so that when I select a single object, whether it be a
base dwg object or an xreference object, the description would show in the
screen message.

(defun C:LID/)
(setvar "cmdecho" 0)
(setq AA (cdr (assoc 8
(entget (car (entsel "Select entity to set layer: "))))))


(setq EL (tblsearch "layer" AA))
(setq A2 (cdr(assoc 2 EL)))
(setq A62(cdr(assoc 62 EL)))

(setq LYRNM A2)
(setq LYRCLR (rtos A62 2 0))

(setq MSG (strcat "Layer: " LYRNM "\n" "\nLayer color: " LYRCLR))
(alert MSG)

)

"gert" wrote in message
news:5747887@discussion.autodesk.com...
what do you mean with layer description?
all layer names of a open drawing
all layer names of a selected xref


KDispoto wrote:

> Using autolisp - how can I obtain the layer description of a selected
> drawing or xreference object?
Message 6 of 13
Anonymous
in reply to: Anonymous

Agreed, with the years all of us
are become by others

~'J'~
Message 7 of 13
Anonymous
in reply to: Anonymous

Oops, I just re-read your request. Sorry, I thought you wanted to add a
description. You can't get to the description thru regular AutoLisp, you
have to use Vlisp (activeX calls to the object model itself)

It's almost the same code to get the description: (use a get instead of a
put)
the following would be inserted just after your setting of AA

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(setq layObj (vla-item theLayers AA)) ;; the layer name you selected
(setq descriptString (vla-get-description layObj))

then you can add the string to your strcat at the end.

Of course, if you want, you can access the other properties of the layer at
the same time with:
(setq layColor (vla-get-color layObj)) ;; same as your A62
or
(setq layLT (vla-get-linetype layObj)) etc.

bytheway, your vars A2 and LYRNAME are not necessary, as AA already is bound
to the name.

If you want to get nested layers, look into using nentsel instead of entsel.

oh, and your defun statement first line should read: (defun C:LID ( / )
[with your variable names after the slash]

good luck,

- the OF


"KDispoto" wrote in message
news:5748046@discussion.autodesk.com...
I appreciate the help - Being that I barely get by with lisp - I am not
familiar with vlisp (although I won't mind trying it here).

Using your code - what is the variable that contains the layer description
(vla-put-description layObj )?


"the Other Frank" wrote in message
news:5747942@discussion.autodesk.com...
here's a few snippets of vlisp to get you going.

(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq theLayers (vla-get-layers acadDocument))
(setq layObj (vla-item theLayers AA)) ;; the layer name you selected
(vla-put-description layObj "This is the layer description")

- the OF

"KDispoto" wrote in message
news:5747872@discussion.autodesk.com...
Ultimately I'd like to add the user defined layer "description" (as it
appears at the far right side of the layer properties dialog box) to the
LID.lsp routine below so that when I select a single object, whether it be a
base dwg object or an xreference object, the description would show in the
screen message.

(defun C:LID/)
(setvar "cmdecho" 0)
(setq AA (cdr (assoc 8
(entget (car (entsel "Select entity to set layer: "))))))


(setq EL (tblsearch "layer" AA))
(setq A2 (cdr(assoc 2 EL)))
(setq A62(cdr(assoc 62 EL)))

(setq LYRNM A2)
(setq LYRCLR (rtos A62 2 0))

(setq MSG (strcat "Layer: " LYRNM "\n" "\nLayer color: " LYRCLR))
(alert MSG)

)

"gert" wrote in message
news:5747887@discussion.autodesk.com...
what do you mean with layer description?
all layer names of a open drawing
all layer names of a selected xref


KDispoto wrote:

> Using autolisp - how can I obtain the layer description of a selected
> drawing or xreference object?
Message 8 of 13
Anonymous
in reply to: Anonymous

"the Other Frank" wrote

>> You can't get to the description thru regular AutoLisp,
>> you have to use Vlisp (activeX calls to the object model itself)


(cdr (assoc 4 (entget (tblobjname "block" "blockname"))))

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
Message 9 of 13
Anonymous
in reply to: Anonymous

Tony,
Wasn't he referring to layer descriptions rather than block descriptions?

Athough may be possible using regular AutoLisp as shown below:

;;This works on my system for 2006, 2008
(defun layerdescription (layname)
(cdr(last(cadr(assoc -3 (entget (tblobjname "layer" layname)
'("AcAecLayerStandard")))))))

that technique would make some large assumptions about application xdata order.

It certainly would be more reliable to get the description by ActiveX right?

Doug

"Tony Tanzillo" wrote in message
news:5748726@discussion.autodesk.com...
"the Other Frank" wrote

>> You can't get to the description thru regular AutoLisp,
>> you have to use Vlisp (activeX calls to the object model itself)


(cdr (assoc 4 (entget (tblobjname "block" "blockname"))))

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
Message 10 of 13
Anonymous
in reply to: Anonymous

I am looking for the layer description. I'd like to display the user defined
layer "description" (as it is entered in the layer properties dialog box)
from of a single selected object, whether it be on the base dwg object or
from an xreference object.

Hope this clears it up:)
Message 11 of 13
Tom Smith
in reply to: Anonymous

What Doug posted will return the layer description for a given layer name. It's kept as extended data in the layer table. You'd have to feed Doug's function the layer of a selected object obtained (for instance) from entsel or nentsel.

Are you sure you need this? Layer descriptions are relatively new, appearing in 2005 for the first time. We haven't yet found a need for them, because we've been muddling along just fine without them for umpteen years. None of your old legacy drawings will include a description. Unless your users have a lot of time on their hands, I'd be surprised if they're actually entering a "user defined layer description" for each layer they use.

If we used them, it would only be as a training tool for new hires, and the standard descriptions would be in the standard layers which come from our standard drawing templates. We discourage users from creating new layers that aren't in the standards.
Message 12 of 13
Anonymous
in reply to: Anonymous

Hi Doug.

Ooops you're right, he was talking about the Layer
description (duh).

And that's also easily obtainable with regular
AutoLISP as you've shown, thanks.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"Doug Broad" wrote in message news:5749331@discussion.autodesk.com...
Tony,
Wasn't he referring to layer descriptions rather than block descriptions?

Athough may be possible using regular AutoLisp as shown below:

;;This works on my system for 2006, 2008
(defun layerdescription (layname)
(cdr(last(cadr(assoc -3 (entget (tblobjname "layer" layname)
'("AcAecLayerStandard")))))))

that technique would make some large assumptions about application xdata order.

It certainly would be more reliable to get the description by ActiveX right?

Doug

"Tony Tanzillo" wrote in message
news:5748726@discussion.autodesk.com...
"the Other Frank" wrote

>> You can't get to the description thru regular AutoLisp,
>> you have to use Vlisp (activeX calls to the object model itself)


(cdr (assoc 4 (entget (tblobjname "block" "blockname"))))

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
Message 13 of 13
Anonymous
in reply to: Anonymous

On a similar note ...
From time to time I use a script to create/update a layer list (name, color,
lineweight..) in a dwg.
Can a script (or other method be used) to create/import a layer list in a
dwg which woud include user defined layer descriptions?
btw: using v2008
Thanks,

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

Post to forums  

Autodesk Design & Make Report

”Boost