delete page setup routine

Discussion in 'AutoCAD' started by jclaidler, Aug 16, 2004.

  1. jclaidler

    jclaidler Guest

    Currently I have a lisp routine to delete all page setups in a drawing. What I need, is to only delete the page setup that doesn't have "WRNP" in the name.

    (defun DeleteOldPageSetup ( Name / Cfgs)

    (setq Cfgs (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))))

    (cond

    ((vl-string-search "*" Name)(vlax-for x Cfgs (if (wcmatch (vla-get-name x) Name)(vla-delete x))))

    (T (vl-catch-all-apply '(lambda () (vla-delete (vla-item Cfgs Name)))))

    )

    (princ)

    )


    (DeleteOldPageSetup "*")



    Thanks for any help.
     
    jclaidler, Aug 16, 2004
    #1
  2. jclaidler

    MP Guest

    how about something like
    (defun DeleteAllButPageSetup ( Name / Cfgs)
    (setq Cfgs (vla-get-plotconfigurations (vla-get-activedocument
    (vlax-get-acad-object))))

    (vlax-for x Cfgs
    (if
    (not (wcmatch (vla-get-name x) Name));if it doesn't match delete it
    (vla-delete x)
    )
    )
    (princ)
    )

    just a quick mod of your code to give the idea - didn't test
    hth
    Mark

    What I need, is to only delete the page setup that doesn't have "WRNP" in
    the name.
     
    MP, Aug 16, 2004
    #2
  3. jclaidler

    jclaidler Guest

    thanks... but that deleted no page setups.
     
    jclaidler, Aug 16, 2004
    #3
  4. jclaidler

    jclaidler Guest

    The code below will delete all page setups WITH "wrnp" in the name. Now all I need is the reverse to happen, to delete page setups NOT with "wrnp".


    (defun DeleteOldPageSetup ( Name / Cfgs)

    (setq Cfgs (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))))

    (cond

    ((vl-string-search "*" Name)(vlax-for x Cfgs (if (wcmatch (vla-get-name x) Name)(vla-delete x))))
    (T (vl-catch-all-apply '(lambda () (vla-delete (vla-item Cfgs Name)))))

    )

    (princ)

    )


    (DeleteOldPageSetup "*WRNP*")


    Message was edited by: jclaidler
     
    jclaidler, Aug 16, 2004
    #4
  5. jclaidler

    T.Willey Guest

    (vlax-for item cfgs
    (if (not (wcmatch (vlax-get item 'Name) "*WRNP*"))
    (vlax-invoke-method item 'Delete)
    )
    )

    This will delete all page setups except ones that have "WRNP" in it.

    Hope this helps
    Tim
     
    T.Willey, Aug 16, 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.