+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Forum Newbie
    Using
    Architecture 2008
    Join Date
    Sep 2008
    Posts
    4

    Default Create Layer Description when creating layers from a pull down menu

    Registered forum members do not see this ad.

    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

  2. #2
    Senior Member TimSpangler's Avatar
    Using
    Architecture 2009
    Join Date
    Jan 2008
    Location
    Gettyburg, PA
    Posts
    212

    Default

    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
    Timothy Spangler
    --theswamp--

  3. #3
    Forum Newbie
    Using
    Architecture 2008
    Join Date
    Sep 2008
    Posts
    4

    Default

    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

  4. #4
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    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.
    Everyone has a Photographic memory, some just don't have film

  5. #5
    Forum Newbie
    Using
    Architecture 2008
    Join Date
    Sep 2008
    Posts
    4

    Default

    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

  6. #6
    Super Moderator rkmcswain's Avatar
    Computer Details
    rkmcswain's Computer Details
    Operating System:
    Windows 7 Pro x64
    Motherboard:
    Intel DZ77RE-75K
    CPU:
    i7-4770K 3.50GHz
    RAM:
    32GB
    Graphics:
    Nvidia Quadro 2000
    Primary Storage:
    125GB SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    ASUS 27" / ASUS 24"
    Discipline
    Civil
    Using
    Civil 3D 2015
    Join Date
    Sep 2005
    Location
    Houston
    Posts
    3,919

    Default

    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.

  7. #7
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    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
    <?xml version="1.0" encoding="utf-8"?>
    <LayerStates>
    <Layer>
    <LayerName>0</LayerName>
    <Freeze>False</Freeze>
    <Locked>False</Locked>
    <Linetype>Continuous</Linetype>
    <Color>7</Color>
    <LayerOn>True</LayerOn>
    <Description>Default Acad Layer</Description>
    </Layer>
    <Layer>
    <LayerName>
    Defpoints
    </LayerName>
    <Freeze>False</Freeze>
    <LayerOn>True</LayerOn>
    <Locked>False</Locked>
    <Linetype>Continuous</Linetype>
    <Color>7</Color>
    <Description>Default Acad Layer</Description>
    </Layer>
    <LayerName>
    SITE-SOND
    </LayerName>
    <Freeze>False</Freeze>
    <LayerOn>True</LayerOn>
    <Locked>False</Locked>
    <Linetype>Continuous</Linetype>
    <Color>1</Color>
    <Description>Sound Measurement Locations</Description>
    </Layer>
    <Layer>
    <LayerName>
    SITE-SOND-TEXT
    </LayerName>
    <Freeze>False</Freeze>
    <LayerOn>True</LayerOn>
    <Locked>False</Locked>
    <Linetype>Continuous</Linetype>
    <Color>80</Color>
    <Description>Sound Measurement Text</Description>
    </Layer>
    </LayerStates>
    Everyone has a Photographic memory, some just don't have film

  8. #8
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    this is the bulk of the code that reads the file
    Code:
          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
    Last edited by CmdrDuh; 11th Sep 2008 at 09:51 pm.
    Everyone has a Photographic memory, some just don't have film

  9. #9
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    Hope this helps
    Everyone has a Photographic memory, some just don't have film

  10. #10
    Super Moderator rkmcswain's Avatar
    Computer Details
    rkmcswain's Computer Details
    Operating System:
    Windows 7 Pro x64
    Motherboard:
    Intel DZ77RE-75K
    CPU:
    i7-4770K 3.50GHz
    RAM:
    32GB
    Graphics:
    Nvidia Quadro 2000
    Primary Storage:
    125GB SSD
    Secondary Storage:
    500GB SATA
    Monitor:
    ASUS 27" / ASUS 24"
    Discipline
    Civil
    Using
    Civil 3D 2015
    Join Date
    Sep 2005
    Location
    Houston
    Posts
    3,919

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by CmdrDuh View Post
    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.

Similar Threads

  1. Make an Image Tile Menu from Pull-Down Menu
    By sumski in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 12
    Last Post: 10th Nov 2009, 12:08 am
  2. Problem with pull down menu dialogue boxes
    By green in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 26th Feb 2008, 04:30 am
  3. Pull Down Menu referencing to blocks
    By AutoCAD Slave in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 3rd Feb 2008, 08:45 am
  4. Layer Pull Down Menu Problems
    By PeterV in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 31st Jul 2007, 03:05 pm
  5. pull down menu paths
    By kentedi in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 4th Jul 2006, 07:07 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts