adrianqy Posted September 11, 2008 Share Posted September 11, 2008 (edited) 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 December 23, 2014 by SLW210 Quote Link to comment Share on other sites More sharing options...
TimSpangler Posted September 11, 2008 Share Posted September 11, 2008 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 Quote Link to comment Share on other sites More sharing options...
adrianqy Posted September 11, 2008 Author Share Posted September 11, 2008 (edited) 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 December 23, 2014 by SLW210 Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted September 11, 2008 Share Posted September 11, 2008 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. Quote Link to comment Share on other sites More sharing options...
adrianqy Posted September 11, 2008 Author Share Posted September 11, 2008 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 Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted September 11, 2008 Share Posted September 11, 2008 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. Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted September 11, 2008 Share Posted September 11, 2008 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 Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted September 11, 2008 Share Posted September 11, 2008 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 Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted September 11, 2008 Share Posted September 11, 2008 Hope this helps Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted September 11, 2008 Share Posted September 11, 2008 Sure, if XML is the way you want to go. As RK said, you could use a CSV file as well. ...and Excel will let you save the data as XML also. Quote Link to comment Share on other sites More sharing options...
adrianqy Posted September 12, 2008 Author Share Posted September 12, 2008 Cheers guys, I'm going to give it a go and see how it goes. Quote Link to comment Share on other sites More sharing options...
JONTHEPOPE Posted September 12, 2008 Share Posted September 12, 2008 TRY SCRIPT FILE . I KNOW I'M NOT THE BEST PROGRAMMER BUT THIS WORKS WELL 4 MEo:) Quote Link to comment Share on other sites More sharing options...
jrocka20 Posted March 6, 2009 Share Posted March 6, 2009 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 Quote Link to comment Share on other sites More sharing options...
kam1967 Posted December 14, 2010 Share Posted December 14, 2010 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 Quote Link to comment Share on other sites More sharing options...
Bharti Pawar Posted December 23, 2014 Share Posted December 23, 2014 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? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 24, 2014 Share Posted December 24, 2014 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. Quote Link to comment Share on other sites More sharing options...
Bharti Pawar Posted December 24, 2014 Share Posted December 24, 2014 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. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 24, 2014 Share Posted December 24, 2014 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") Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.