Does anyone have a LISP to modify all open drawings

Discussion in 'AutoCAD' started by Curtis Kostecki, Aug 5, 2003.

  1. I am looking to perform a series of cleanup utilities during a "save all"
    drawings to Autocad 2004. I started with the express tools saveall.lsp
    calling a sub function (of utilities lisp routines) -> Shown as a line from
    0,0 to 1,1 in the attached code
    However, it is only performed in the current open drawing? While all other
    saves are performed as "transparent" saves not actually accessing the actual
    drawing.
    I end up with a line in one drawing written over itself the same number of
    times as the quantity of open drawings.

    Can anyone suggest how this saveall lisp could be adjusted to invoke a
    subroutine on all open drawings before opening them?
    It could even close them one by one if necessary..

    Can anyone help or does anyone have a similar routine?

    Thanks in advance
    Curtis

    ;*********************Save all lisp from AutoCad ******************
    ;************************ Utility codes added ********************
    (defun C:SALL (/ dwg saveDwg)
    ;; save drawing
    (defun saveDwg (dwg / titled writeable name)
    (setq titled (= 1 (vlax-variant-value (vla-getvariable dwg
    "DWGTITLED")))
    ;writable is whether or not the drawing is read only
    writeable (= 1 (vlax-variant-value (vla-getvariable dwg
    "WRITESTAT")))
    ; Name is the drawing path name
    name (if titled (vlax-get dwg "fullname")
    (vlax-variant-value (vla-getvariable dwg "DWGNAME")) )
    )
    (cond
    ;; REFEDIT active Subroutine
    ((/= "" (vlax-variant-value (vla-getvariable dwg "REFEDITNAME")))
    (acet-ui-message
    (acet-str-format "%1\nCannot Save while REFEDIT active." name)
    "AutoCAD - SAVEALL"
    Acet:ICONSTOP )
    )
    ;; simple save if titled and writeable
    ((and titled writeable)
    (Prompt "Saved1/Name =")(Princ Name)(prompt " ")
    (command "line" "0,0,0" "1,1,0" "")
    (vla-save dwg)
    )
    ;; otherwise ask for name first if drawing is read only..
    (T
    (if (setq name (ACET-FILE-WRITEDIALOG "Save Drawing As" name "dwg"
    1))
    (progn (vla-saveas dwg (vlax-make-variant name))
    (command "line" "0,0,0" "1,1,0" ""))
    )
    )
    )
    )
    ) ;; quietly
    (acet-error-init '(("CMDECHO" 0)))
    ;; for each drawing
    (vlax-for dwg (vla-get-documents (vlax-get-acad-object))
    ;; save if modified
    (if (/= 0 (vlax-variant-value (vla-getvariable dwg "DBMOD")))
    (progn
    (saveDwg dwg)(command "line" "0,0,0" "1,1,0" ""))
    )
    )
    (acet-error-restore)
    (princ)
    )
     
    Curtis Kostecki, Aug 5, 2003
    #1
    1. Advertisements

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.