; ** 12-Sep-07 NEHolt ; ----- A C E _ Z I P _ P R O J E C T . L S P ------ (defun ace_zip_project ( wdpfnam zipfname / x zipexe data dlst f curdwg_in_zip dwg tmpfname zip_extension curdwg) ; Purpose: zip target project without user prompts ; "wdpfnam" = nil for active project, otherwise = ; full path/name of project ".wdp" file ; "zipfname" = zip file to create ; Set path to ZIP executable here (if (setq x (getenv "ProgramFiles")) (setq zipexe (strcat x "\\winzip\\winzip32.exe")) ; ELSE (setq zipexe "c:\\program files\\winzip\\winzip32.exe") ) (cond ((AND zipexe (wcmatch (strcase zipexe) "*RAR.EXE")) (setq zip_extension "RAR")) (T (setq zip_extension "ZIP")) ) ; Delete any old zip file (if (setq x (findfile zipfname))(c:wd_del_file x)) (if (OR (= wdpfnam nil)(= wdpfnam "")) (progn ; Get active project and list of data from its ; ".wdp" project file (setq data (c:wd_proj_wdp_data)) (setq dlst (nth 5 data)) ; list of dwgs - full path names (setq wdpfnam (car data)) ) ; ELSE (progn ; Specific project (not necessarily the active one) (setq data (c:wd_proj_wdp_data_fnam wdpfnam)) (setq dlst (nth 4 data)) ; list of dwgs - full path names ) ) (if (AND wdpfnam (/= wdpfnam "")) (progn (setq wdpfnam (wd_all_slashes_backward wdpfnam)) ; Create an ascii text file listing all drawings to zip (setq tmpfname (strcat GBL_wd_usr "wdzip.tmp")) (if (setq f (open tmpfname "w")) (progn ; empty file created ; Write out the project's ".wdp" file (write-line wdpfnam f) (setq curdwg (ace_strcase (wd_all_slashes_backward (wd_zip_current_full_name)))) (setq curdwg_in_zip nil) (foreach dwg dlst ; Make sure all slash characters are backslashes (setq dwg (wd_all_slashes_backward dwg)) (write-line dwg f) ; write dwg name out to ascii file ; Check if dwg file to be zipped is the same as the ; current dwg. If so, alert user the ZIP may fail. (if (= (ace_strcase dwg) curdwg) (setq curdwg_in_zip dwg)) ) (close f) (setq f nil) (if curdwg_in_zip (princ "\nProblem with opened dwg added to ZIP file.")) (cond ((= zip_extension "RAR") (startapp zipexe (strcat "a \"" zipfname "\" \"@" tmpfname "\""))) (T (startapp zipexe (strcat "-a -p \"" zipfname "\" @" tmpfname))) ) ) ) ) ) (princ) )