Author Topic: Batch: Open DWG plus Lisp from another lisp?  (Read 7075 times)

0 Members and 1 Guest are viewing this topic.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #15 on: March 26, 2014, 01:58:58 PM »
The only solution that I have found to be able to "batch" in lisp is a little drawn out.  I will try to explain it as simply as I can.

The solutions uses the registry and the acaddoc.lsp.

The acaddoc.lsp loads the "batch.lsp" (this is the executing lisp).  In this lisp there is some code that checks the registry for a flag (and a few other things)

;;From the acaddoc.lsp;;
Code: [Select]
;; Appload the Batch program
(load "Batch.lsp")
;;From the Batch.lsp
Code: [Select]
(setq BatchMasterKey "HKEY_CURRENT_USER\\Software\\Batch")

(if (= (vl-registry-read BatchMasterKey "Run") "T")
;; Run the batch if it is not nil
(load (vl-registry-read BatchMasterKey "Batch") "Unable to load the specified Batch!")
)

When the executing lisp is run, it creates a document reactor in the current drawing which checks for that drawing to become current again.  Then it sets the registry flags that are read by the opening lines of the batch.lsp. Then the drawings are opened. (there is a little more detail here that I am skipping).  One of the registry flags is a lisp file (this is the "batch process"). This is loaded into the (s:startup) so that it will execute once the drawing is fully opened.

Since the flag has been set, when the drawings begin to open the "batch process" is executed automatically. Once the drawing is fully opened, the "batch process" runs.  (this "batch process" closes the drawing when it is complete).  Once all of the drawings have been "processed" and the current drawing takes focus, the reactor resets the flags in the registry and deletes the reactor.

Example of a "batch process":
Code: [Select]
;; Add the start up
(defun S::STARTUP (/)

;;; ------------ ECHO TO THE COMMAND LINE
(princ "\n Begining Batch Process \n")

;; Set the dbmod
(acad-push-dbmod)
;; Run some shtuff
(alert "test")
;; Reset the dbmod
(acad-pop-dbmod)
;; Close the drawing
(vl-cmdf "CLOSE")
)
[\code]

This seems to work for me with out any issue.  I tried using scripts to batch process but if it fails, it stops.  Since I am using lisp I can capture and report errors with out stopping.  Also since I am using lisp and a document reactor I can set other flags to execute after the batch has been completed. I am able to execute .lsp, exe, .vbs, open documents, open explorer, send email, endless possibilities.

ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

Peter2

  • Swamp Rat
  • Posts: 653
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #16 on: March 26, 2014, 02:07:42 PM »
Hi Tim

thank you. I will study and try. At the moment there seem to be a solution based on OpenDCL. I will try there too and will report.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23