View Full Version : Adding a description to the Layer
martyk
2007-04-12, 08:10 PM
I have a lisp routine that will create standard layers based on NCS. Based on the portion of code I have included, is there a way of adding a Description to the layer through this method? Is there another option other than creating the layers and descriptions in a template drawing and importing them through Design Center? Thanks!
"make" "H-ANNO-DIMS" "color" "1" "" "ltype" "DASHED" ""
tyshofner
2007-04-12, 09:41 PM
I'm pretty sure you can't add it through the layer command, but you could probably add it through LISP. Or you could just a make blank drawing that already has the layers in it, then make a button to insert that drawing as a block (and explode it when inserted). This will bring the layers (and all of their properties) into the current drawing. Only problem with this method is if the layer is already in the current drawing it will just use those properties (i.e. it won't "fix" a layer that has been changed in the current drawing).
Ty :mrgreen:
I have a lisp routine that will create standard layers based on NCS. Based on the portion of code I have included, is there a way of adding a Description to the layer through this method? Is there another option other than creating the layers and descriptions in a template drawing and importing them through Design Center? Thanks!
"make" "H-ANNO-DIMS" "color" "1" "" "ltype" "DASHED" ""Good Question....
I know you can change the description through the layer dialog but I don't know how to access that data through lisp.
Maybe there's something in the "Standards" options?
tyshofner
2007-04-13, 02:41 PM
Example of changing the description for every layer in the drawing:
(defun C:TEST ( / cnt lay lay_col lay)
(setq cnt 1)
(setq lay_col (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for lay lay_col
(vla-put-description lay (strcat "Description-" (itoa cnt)))
(setq cnt (1+ cnt))
)
(princ)
)
Obviously this is very simple but it can be expanded upon.
Ty :mrgreen:
martyk
2007-04-13, 02:57 PM
I was hoping there was a quick way of creating new layers in a drawing other than Design Center. Maybe even a script routine? What I'm looking for is a quick, one or two click, way of creating layers in a new drawing. Maybe there's even a way of automating insertion from Design Center? I do like the idea of using a lisp routine because it "makes" the layers and dictates how the layers should look. I could use this routine for creating the layers at the beginning, but I could also use this routine for correcting layers if someone has changed them from the standard. I am open to other suggestions. But I would like to have Descriptions built into the layers when they are created. If I were to import layers from a template drawing through Design Center, will they override what is currently in the drawing? All input is welcome! Thanks!
I was hoping there was a quick way of creating new layers in a drawing other than Design Center. Maybe even a script routine? What I'm looking for is a quick, one or two click, way of creating layers in a new drawing. Maybe there's even a way of automating insertion from Design Center? I do like the idea of using a lisp routine because it "makes" the layers and dictates how the layers should look. I could use this routine for creating the layers at the beginning, but I could also use this routine for correcting layers if someone has changed them from the standard. I am open to other suggestions. But I would like to have Descriptions built into the layers when they are created. If I were to import layers from a template drawing through Design Center, will they override what is currently in the drawing? All input is welcome! Thanks!If you have a master template drawing, (or atleast a drawing with layers you want) you can drag and drop the layers from that into your drawing using Design Center.
But unfortunately they won't overwrite the existing ones..(maybe I should have read further)
When you say "descripton" do you mean what's in the layer dialog?
I would imagine if you have the discriptions already set up, and ran the the "make layers" routine, that desicription wouldn't change, but the modified layers would update per the routine.
Just a guess.
tyshofner
2007-04-13, 03:37 PM
It's Friday (I've got nothing else to do) so here is another example. I'm not sure exactly how you want to obtain the information for the layers but this routine could be adapted to suit just about any need. I would recommend either using a list of some sort or maybe reading the layer information from an external file. Here's the code:
(defun C:TEST2 ( / lay_name lay_clr lay_lin lay_desc lay)
(vl-load-com)
(setvar "cmdecho" 0)
(setq lay_name (getstring T "\nSpecify layer name: ")
lay_clr (getint "\nSpecify layer color: ")
lay_lin (getstring T "\nSpecify layer line type: ")
lay_desc (getstring T "\nSpecify layer description: ")
)
(if (not (tblsearch "LTYPE" lay_lin)) (command "-linetype" "L" lay_lin "acad.lin" ""))
(setq lay_col (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(if (= (tblsearch "LAYER" lay_name) nil)
(vla-add lay_col lay_name)
)
(setq lay (vla-item lay_col lay_name))
(vla-put-color lay lay_clr)
(vla-put-linetype lay lay_lin)
(vla-put-description lay lay_desc)
(setvar "cmdecho" 1)
(princ)
)
Ty :mrgreen:
jaberwok
2007-04-13, 09:49 PM
Use the blank-drawing-with-predefined-layers idea but insert an existing drawing into that to update altered layer properties as inserting the blank into an existing drawing does not alter the properties of existing layers. Or run a script to standardise the properties.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.