PDA

View Full Version : Layer Descriptions


cadconcepts
2007-10-14, 05:04 PM
Hello Everyone-

I was recently asked if I could modified a routine I wrote to load layers to include layer descriptions as shown in the layer dialog box. Try as I might, I cannot seem to locate where this value is stored. I did a tblsearch on the layer and nothing. I even tried to add a description to the layer from the command line (-layer) and the description field is not there. Any help is greatly appreciated. Thanks in advance.

Manuel A. Ayala
CAD Concepts

rkmcswain
2007-10-15, 04:04 AM
Stored as XData.

Try this: (entget (tblobjname "layer" "Text") '("*"))

d_m_hopper
2007-10-15, 05:25 AM
I want to see this work, after searching for this answer before in the past and earlier today. I just made a drawing with all layers plus descriptions in it and have my team insert it if they purge them on accident. For right now they are part of the dwt for new drawings

Mike_R
2007-10-17, 05:05 PM
Easiest with VLISP...

(vl-load-com)
(vla-put-description
(vla-item
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
)
)
"LAYER"; put your layer name here
)
"DESCRIPTION"; Put your wanted layer description here
)

d_m_hopper
2007-10-17, 10:02 PM
Easiest with VLISP...

(vl-load-com)
(vla-put-description
(vla-item
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
)
)
"LAYER"; put your layer name here
)
"DESCRIPTION"; Put your wanted layer description here
)



how do I do this so it works with several layers at a time?

I tried "layer,layer'layer" & "desc,desc,desc"

key not found error?

one at a time not a problem

Opie
2007-10-17, 10:24 PM
how do I do this so it works with several layers at a time?

I tried "layer,layer'layer" & "desc,desc,desc"

key not found error?

one at a time not a problem
You can't. You could put it in a loop to do what you need.

d_m_hopper
2007-10-17, 11:17 PM
You can't. You could put it in a loop to do what you need.


Good to know thanks

Mike_R
2007-10-17, 11:26 PM
how do I do this so it works with several layers at a time?

I tried "layer,layer'layer" & "desc,desc,desc"

key not found error?

one at a time not a problem

That's a bit more intensive, but still not too difficult.... You just have to step through the layer collection and add the description to each. vlax-for, mapcar, and lambda are the key functions for this one.


(defun c:describe ()
;;;Do the mapcar function for each layer in the drawing.
(vlax-for layer
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)
)
)
;;;if the current layer being checked matches a predetermined name, add the needed description.
(mapcar
(function
(lambda (layname description)
(if (= (strcase (vla-get-name layer)) (strcase layname))
(vla-put-description layer description)
()
)
)
)
'("layer_name_1" "layer_name_2" "layer_name_3" "etc"); This is your list of layers needing a description.
'("description1" "description2" "description3" "ect"); This is the descriptions for each layer. Make sure the order is EXACTLY the same as in the layer list.
)
)
(princ); Silent exit.
)

If there's any mistakes in this, I apologize. I just threw it together real quick in VLISP and ran a single error check. No test runs.