Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

question: multi-drawing processing using a script

2 REPLIES 2
Reply
Message 1 of 3
m_simons
517 Views, 2 Replies

question: multi-drawing processing using a script

Hey all,

 

I have two questions regarding processing multiple drawings with a script. I have written a LISP utility which generates a script file that performs certain functions to selected drawings. (like this)  Everything works great except for two issues.

 

First: when the script is called from LISP, autocad hangs until the user moves the mouse, then the script runs fine.

 

Second: I'm having an issue with file handling. I am able to determine if the file is read only, or if it is available for write access. However I'm running into problems if the user has multiple drawings open on a machine and the utility needs to access these drawings. Of course they show as read only, so I can have the utility skip over them, however this is silly. Is there a way to have autocad "activate" a currently open but non-active drawing? I have some understanding of visual lisp, but can't seem to put a command in this script file that will "activate" a currently open drawing for write access.

 

Some additional info: I'm running autocad electrical 2009. Here are some code fragments that generate the script file, and the script file itself.

 

;;fragment of code from the utility

(if upd_sig_lst    ; if the utility needs to process many drawings
  (progn
    (setvar "filedia" 0)     ; turn off dialogs for open file in script
       (vl-propagate 'upd_sig_dwglst)    ; propagate lists used in dwgs
       (vl-propagate 'upd_sig_hdllst)
       (vl-propagate 'upd_sig_wirlst)
       (vl-propagate 'upd_sig_uidlst)
       (create_process_scr opt1)         ; run function that creates .scr
       (if (= opt1 0)
         (c:ace_update_WFRM2ALL 1)  ; update scratch database if needed
       )
       (command "_.SCRIPT" temp_scr)	; ACAD hangs here
       (setvar "filedia" 1)          ; turn dialogs on
     )
   )


;; function that creates script

(defun create_process_scr (opt / dwg_lst) ; needs error trapping!
  (setq scr_hdl (open temp_scr "w"))					
  (setq dwg_lst (list))
  (setq opt (itoa opt))
  (princ "\nProcessing signals on sheets:")
  (if scr_hdl
    (progn
      (foreach i upd_sig_dwglst
        (progn
          (if (not (member i dwg_lst))
	    (progn
	      (princ "\n")(princ (vl-filename-base i))
	      (write-line (strcat "_.OPEN \"" i "\"") scr_hdl)
	      (write-line (strcat "(C:EEP_UPDATE_DSTNTN " opt ")") scr_hdl)
	      (write-line "_.QSAVE" scr_hdl)
	      (write-line "_.CLOSE" scr_hdl)
	      (setq dwg_lst (append dwg_lst (list i)))
	    )
	  )	
        )
      )
      (close scr_hdl)
    )
  )
)

;; here is an example of a script the utility produces

_.OPEN "//SERVER7/PROGRAMS/ACTIVE/CAD-ELECTRICAL LIBRARY/AUTOCAD ELECTRICAL PROJECTS/5555 TEST HOT/5555001_003.DWG"
(C:EEP_UPDATE_DSTNTN 1)    ; this is a function I have defined and tested
_.QSAVE
_.CLOSE
_.OPEN "//SERVER7/PROGRAMS/ACTIVE/CAD-ELECTRICAL LIBRARY/AUTOCAD ELECTRICAL PROJECTS/5555 TEST HOT/5555001_005.DWG"
(C:EEP_UPDATE_DSTNTN 1)
_.QSAVE
_.CLOSE

 

 

Any help would be hugely appreciated.

 

Thanks!

2 REPLIES 2
Message 2 of 3
ales.stanek
in reply to: m_simons

Hello,

  1. If I remeberd correctly than command open have four choices open, open for read, partialy open and partialy open for read.
  2. Whay you don't use ScriptPro 2.0?

 

Best Regards

Message 3 of 3
m_simons
in reply to: m_simons

I looked into script pro. Though an interesting piece of software that I will probably use in the future, it will not work in this case. The batch processing needs to be transparent to the user. It just needs to happen based on which drawings the LISP utility determined need to be processed.

 

Also I tried to find what parameters _,OPEN is looking for and it seems that file name is the only thing, if I put anything else in there it fails.

 

Also I should have noted, after my program creates the script. I can run the script by itself just fine and it runs without hanging. It only hangs when it is called from the lisp routine. I'm wondering if it has something to do with the lisp routine finishing up on the first drawing AS the script is running on other drawings. (because as we all know, autoCAD has issues handling multiple drawings from a LISP stand point).

 

Thanks for the help, any more ideas?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost