Delete/remove layouts using LISP

Discussion in 'AutoCAD' started by dhorton, Aug 20, 2004.

  1. dhorton

    dhorton Guest

    Hello,

    I'm trying to par down some drawings to what's contained just in model space.....basically i'm wanting to delete all the layout tabs without mouse/keyboard imput. The layouts vary in quantity and in name.
    I am aware that there is a need for at least one layout, but this can be the default one generated by ACAD.
    BTW, how goes one create a selection set of viewports and one of layouts.

    Thanks in advance

    Dom
     
    dhorton, Aug 20, 2004
    #1
  2. dhorton

    Joe Burke Guest

    Dom,

    Try this. You might remove the confirm checking part, if so desired. That would be
    Jason's original code.

    ;; original code by Jason Piercy
    ;; modified JB 7/26/2004 to add Y/N caution
    (defun c:DelTabs ( / confirm )
    (princ "\nCaution: this will delete all layouts and data contained in layouts. ")
    (initget 1 "Y N ")
    (setq confirm (getkword "\nProceed? [Yes/No] <Y>: "))
    (if (or (= confirm "") (= confirm "Y"))
    (vlax-for x (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
    (if (/= "Model" (vla-get-name x))
    (vla-delete x)
    )
    )
    (princ "\nLayouts were not deleted. ")
    )
    (princ)
    ) ;end

    Joe Burke

    space.....basically i'm wanting to delete all the layout tabs without mouse/keyboard
    imput. The layouts vary in quantity and in name.
     
    Joe Burke, Aug 20, 2004
    #2
  3. dhorton

    dhorton Guest

    Thanks Joe,

    I've parred your code down and it works fine. I'm new to AutoLISP, even newer to VLISP, just for reference, what do the commands mean and how does it work!?
    thanks again

    dom
     
    dhorton, Aug 20, 2004
    #3
  4. dhorton

    Joe Burke Guest

    Dom,

    You're welcome.

    Following is Jason's original code.

    (defun c:DelTabs ()
    (vl-load-com)
    (vlax-for x
    (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
    (if (/= "Model" (vla-get-name x)) (vla-delete x))
    )
    )

    It looks at the layout collection in the active document. The (vlax-for x... function
    is similar to the foreach function in standard LISP. Rather than accepting a list as
    an argument, it expects a collection argument. See developer help regarding what
    qualifies as a collection when using vlisp/activeX.

    Post more questions here if you are still confused.

    Regards
    Joe Burke



    VLISP, just for reference, what do the commands mean and how does it work!?
     
    Joe Burke, Aug 20, 2004
    #4
  5. dhorton

    dhorton Guest

    cheers!

    i think a bit of reading is required!

    thanks once again

    dom
     
    dhorton, Aug 20, 2004
    #5
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.