+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 36
  1. #1
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Nov 2007
    Posts
    136

    Default Delete layer using VBA

    Registered forum members do not see this ad.

    Hello!
    I am using lisp code to configure autocad. I have zerro understanding about VBA. The thing why i need VBA is to delete layer. I can delete layer using lisp, but after the command i cant activate vports in layouts using double click. Only after reopening the drawing i can activate vports using double click. So idea is to delete layer using VBA and then lets see what happens.
    If someone who uses VBA could write the code that would pick up value from lisp variable named "LAYDEL-NAME" and delete the layer, I'd be very thankful.

    Variable value might be forexample:
    Code:
    (setq LAYDEL-NAME "Layer1")

  2. #2
    Senior Member borgunit's Avatar
    Using
    Mechanical 2014
    Join Date
    May 2007
    Location
    Ohio USA
    Posts
    287

    Default

    Remember that the same rules apply as when you purge, you may not be able to do this if the layer contains something.

    Code:
    ThisDrawing.Layers.item("layername").Delete
    AutoCAD Mechanical 2014
    WIN 7
    http://mechcad-insider.blogspot.com/

  3. #3
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Nov 2007
    Posts
    136

    Default

    I have objects there that I also want to delete.. This code is not working from the command line.. How shall i write it?

  4. #4
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Nov 2007
    Posts
    136

    Default

    I wrote a lisp, that deleted all the objects from this layer.. So this is not a problem.. Now i need to delete the layer but the code line of yours still dont work.. How can I pass my variable to it?

  5. #5
    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

    So you can successfully delete all objects from the layer? What variable are you passing?
    Everyone has a Photographic memory, some just don't have film

  6. #6
    Super Member
    Using
    Architecture 2009
    Join Date
    Apr 2008
    Location
    London, (sunny UK)
    Posts
    686

    Default

    Why not use LAYDEL?
    I can help with VBA if you want, but bog standard ACAD works just as good...

  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

    what about this
    (command "vbastmt" "ThisDrawing.Layers.item("layername").Delete")
    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

    ok, that didn't work
    Everyone has a Photographic memory, some just don't have film

  9. #9
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Nov 2007
    Posts
    136

    Default

    If in the routine i use LAYDEL then in forth time i run this command i got error and must restart autocad.. Thats why i came with idea to use VBA and pass some vlisp variable that contained the name of the layer to delete as string..

  10. #10
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Nov 2007
    Posts
    136

    Default

    Registered forum members do not see this ad.

    Also strange thing happens. I dont really understand if its becaus Im using (command "explode" ...) or laydel, but the thing that happens is, that after command is done i cant go to the paperspace using double click in free space.. i can do it with pspace command. but when i wish to activate the vport, then i cant do it with double click.
    When i remove the xplode code part and reopen the drawing, everything seems ok with the activating part.. and when i write the explode code line and reload, then it also works.. but when i reopen the drawing and lisp file is automaticaly loaded, then after the command i cant activate vports using double click.. ITS a MYSTERY>>

Similar Threads

  1. Delete Layer Error
    By AMB4311 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 7
    Last Post: 14th Mar 2008, 02:51 pm
  2. layer just wont delete
    By tfeiller in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 14th May 2007, 09:44 am
  3. Delete Layer
    By CAD-e-Corner in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 8th May 2007, 07:10 pm
  4. How do I delete part of layer Name
    By Cymro in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 15th Dec 2006, 03:44 pm
  5. Delete Layer(s)
    By CADTutor in forum Application Archive
    Replies: 0
    Last Post: 3rd Dec 2004, 08:12 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