Jump to content

Create Layer Description when creating layers from a pull down menu


adrianqy

Recommended Posts

Hi there, I am bulding a custom drop down menu for creating layers which creates the layer name, description and sets the layer colour, linetype and lineweight. I am really new to macros and lisp so dont really know the best way to do that. I came up with this after browsing different sites.

 

^C^C^C(setq clyr (getvar "clayer"))(setq LayObj(vla-add(vla-get-layers(vla-get-ActiveDocument(vlax-get-acad-object)))"A-004-DOOR_ID"))(vla-Put-Description layObj "Identification Tags Doors numbers")(vla-put-Color layObj "9")(vla-put-LineType layObj "CONTINUOUS")(SETVAR "CLAYER" "A-004-DOOR_ID")(setvar "clayer" CLYR)

 

Could somebody give me a hand with this routine, please. I would like the layer to be made current as well. I just don’t know why in not working.

 

Another question I have, is this the easiest way to create a layer from a drop down menu , thinking that I have 1000 layers in my list.

 

 

cheers

Adrian

Edited by SLW210
Link to comment
Share on other sites

That's a heavy job for a macro (100 layers) Try something like this instead:

LayerCreator

 

What you want can be done but I think you maybe better off calling a lisp from the menu. If that is the road you would like to take I can help.

 

TIM

Link to comment
Share on other sites

Hi Tim, I've got to say, I do like your approach. However, in our office, we've decided to go down the drop down menu way and because we’ve got couple of offices across the country I need to come up with something tidy that goes easy from the network on the end user. I started creating this cui file and at the beginning I was using this routine to bring the layer into my file:

 

 ^C^C.-layer m A-002-ANTN c 6 A-002-ANTN lt CONTINUOUS;;;

The only thing with this method is that it doesn’t include the layer description in the layer manager. So after some more digging I have found another routine but it just not working in 2008:

 

^C^C-la;m;A-001-BLK_INSRT;c;2;A-001-BLK_INSRT;lw;0.35;;l;continuous;A-001-BLK_INSRT;_D;(Bearings,Distances,Co-ordinates);A-001-BLK_INSRT;;

I would really appreciate your help if you’ve got the time , thenk you very much

 

Adrian

Edited by SLW210
Link to comment
Share on other sites

Well, from a housekeeping perspective, you are createing a management nightmare in my opinion. What you are doing will work, but you have to hand program every layer in the cui editor, which could take forever. On top of that, if you have to make a change, you have to send the CUI to everyone that needs it to update their machine. You should look into either a LISP or VBA solution that reads an external file that you could post on the network that your users point to for updates. That way you update the file on the network, and the users are updated as soon as you hit save. I use XML for my file on the network, which allows me to do everything you want. You could then call it from your cui file drop down menu. You could also have multiple files for different offices or different projects.

Link to comment
Share on other sites

Hi CmdrDuh

Thank you very much for your reply, would it be to much to ask you to give me a hand with the xml file, please ? I don’t know how to do that and I think will definitely be a better solution than mine.

Cheers ,

 

Adrian

Link to comment
Share on other sites

Yea, don't do this with a macro.

 

One way - Create a CSV file in Excel that stores the Layer Name, color, linetype, etc.

Then write a lisp routine to read this file and create the layers.

This way you can alter the CSV at any time and the routine is instantly updated.

Link to comment
Share on other sites

Sure, if XML is the way you want to go. As RK said, you could use a CSV file as well. Here is a very small portion of my XML file, and I will post the VBA code that reads it next

0

False

False

Continuous

7

True

Default Acad Layer

Defpoints

False

True

False

Continuous

7

Default Acad Layer

SITE-SOND

False

True

False

Continuous

1

Sound Measurement Locations

SITE-SOND-TEXT

False

True

False

Continuous

80

Sound Measurement Text

Link to comment
Share on other sites

this is the bulk of the code that reads the file

      On Error GoTo Err_Control
     Dim objXML As New DOMDocument
     Dim objRoot As IXMLDOMElement
     Dim objLNode As IXMLDOMElement
     Dim objLayer As AcadLayer
     Dim strFile As String
     ThisDrawing.ActiveLayer = ThisDrawing.Layers("0")
     
     strFile = "C:\Program Files\autocad 2008\TEP SUPPORT\TEPLayers.xml"
     objXML.Load strFile
     Set objRoot = objXML.documentElement
     For Each objLNode In objRoot.childNodes
           Set objLayer = ThisDrawing.Layers.Add(objLNode.childNodes(0).Text)
           If Not ThisDrawing.ActiveLayer.Name = objLayer.Name Then
                 objLayer.Freeze = objLNode.childNodes(1).Text
                 objLayer.LayerOn = objLNode.childNodes(2).Text
     'objLayer.Lock = objLNode.childNodes(3).Text
                 objLayer.Linetype = objLNode.childNodes(4).Text
                 objLayer.color = objLNode.childNodes(5).Text
                 objLayer.Description = objLNode.childNodes(6).Text
           End If
     Next objLNode
     Set objXML = Nothing
     Exit Sub

Link to comment
Share on other sites

  • 5 months later...

I have a related question with the layer creation menu.

 

I would like to create multiple layers with one menu click. So far, I understand the (is it LISP?) codes.

 

^c^c-layer;n;LAYER-001;LT;DASHED;C;RED;;
Unfortunately, I don't know how to string together multiple layer creation commands so that the command will work. I know that you could make it all one line, but I would prefer each layer have its own line (for ease of future editing). How do I string each separate line to read as one continuous command string?

 

Any thoughts?

 

Thanks,

jason

Link to comment
Share on other sites

  • 1 year later...

Tim - awesome layer routine. Can you tell me how many layers this routine would import? I tried to import the lyr file exported by this LayerCreator program and it prevents me from selecting all for importing into the drawing and gives me this message: Capacity of tiles lyr_names exceeded.

 

Is it possible to allow the program to accommodate more layers? If so, I would really appreciate it if you can fix the program. Thank you. This is a very cool program! You're awesome.

 

That's a heavy job for a macro (100 layers) Try something like this instead:

LayerCreator

 

What you want can be done but I think you maybe better off calling a lisp from the menu. If that is the road you would like to take I can help.

 

TIM

Link to comment
Share on other sites

  • 4 years later...
That's a heavy job for a macro (100 layers) Try something like this instead:

LayerCreator

 

What you want can be done but I think you maybe better off calling a lisp from the menu. If that is the road you would like to take I can help.

 

TIM

 

Why is this error msg getting displayed? I am new to autoCAD. How do I run this file?Capture.JPG

Link to comment
Share on other sites

Its looking for a file called "layer creator.dcl" it will pop a display on the screen just like your error message. Go back to the link it must have two parts.

Can u please give me step by step instructions to run this code? I am new to AutoCAD. :)

Link to comment
Share on other sites

The other way to approach this and it does not matter how many layers is to use a text file with all the layer details easy to add/subtract just set it up as a fixed length or as a csv file. It will almost instant create say 100+ layers. Just a simple lisp to read the file or files.

 

1234567890123456789012345678901234567890

Newname prog name Col Line Type

ceiling--2 ceiling--2 6 continuous

ceiling--3 ceiling--3 6 continuous

ceiling--5 ceiling--5 6 continuous

 

; the menu or toolbar something like this loads file layer1
[Layer1]^C^C^P(load "newLayer")(newlay "layer1") 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...