Deleting Layers with Lisp

Discussion in 'AutoCAD' started by Scott, Dec 22, 2003.

  1. Scott

    Scott Guest

    Does anybody here know how to delete a layer using lisp? The layer has
    nothing on it, and can be deleted, I would rather not use the purge command
    as it write a bunch of junk to the command line when purging a layer.

    TIA

    Scott
     
    Scott, Dec 22, 2003
    #1
  2. try this:

    ;; type the layer name you want to delete
    (setq layer_name "a-dim")

    (if (not (vl-catch-all-error-p
    (setq vla_layer (vl-catch-all-apply
    'vla-item
    (list (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)))
    layer_name)))))
    ;; if is possible it will be deleted...
    (vl-catch-all-apply 'vla-delete (list vla_layer)))

    hth.
     
    Luis Esquivel, Dec 22, 2003
    #2
  3. Scott

    Doug Broad Guest

    The layer symbol must be set to the layers collection. It is
    not just a magic word. ;-)

    (setq layer (vla-get-layers(vla-get-activedocument(vlax-get-acad-object))))
     
    Doug Broad, Dec 22, 2003
    #3
  4. Scott

    Doug Broad Guest

    Luis probably got you going. In addition, given the previous message:

    (vla-delete (vla-item layer "fitting temp"))
     
    Doug Broad, Dec 22, 2003
    #4
  5. This would be one way.

    (vla-delete (vlax-ename->vla-object (tblobjname "layer" "layer1"))


    PS: Glad you see my first post, because I sure don't.
     
    Jason Piercey, Dec 22, 2003
    #5
  6. Scott

    Scott Guest

    Great it works now! Thanks to everybody who added their ideas!

    Scott
     
    Scott, Dec 22, 2003
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.