Bill Tillman Posted January 10, 2013 Posted January 10, 2013 (edited) I'm working on a project which creates a dwg and a PDF file of that drawing. I need to WinZip these two files together for sending out later. My thinking is to use a batch file that will be started from LISP but I need to pass a single command line argument to it so the zip file will be properly named. This command line argument will be a variable which changes with each run of the program. Anyone ever done this? I'm also thinking I might write the batch file on the fly from LISP and then launch it. This way there would be no need for arguments. Edited January 10, 2013 by Bill Tillman Quote
BlackBox Posted January 10, 2013 Posted January 10, 2013 I'm working on a project which creates a dwg and a PDF file of that drawing. Consider the AUTOMATICPUB System Variable. Anyone ever done this? I'm also thinking I might write the batch file on the fly from LISP and then launch it. This way there would be no need for arguments. vl-Filename-Mktemp? Quote
Bill Tillman Posted January 10, 2013 Author Posted January 10, 2013 Hey that AUTOMATICPUB looks interesting for some other tasks I have in mind. Thanks. This task requires that a file be named with the unique ID number which was assigned when the user requested the drawing. We're actually going live with this tomorrow on the Internet so I got my work cut out for me to finish it by tonight. The batch file will prepare the zip file but I need this zip file to be named unique-ID#.zip and each one will be different. And it's totally automated so I can't ask the user to do anything. In fact the users are now making these requests through their web browser, no more Excel, and they don't even need AutoCAD. Yesterday was my 1 year anniversary at this client and we have come a long way. The idea I have is to let the LISP program write the batch file and then startapp to run it. This way the batch file can include all the variables and they will be assigned to the actual path names. I am having some trouble with all the / \ and ". But here is what I need the line to look like in the batch file once it's ready to go. @echo off C:\Program Files\7-zip\7z.exe C:\xampp\htdocs\out\unique-ID#.zip c:\temp\unique-ID#.* Quote
BlackBox Posted January 10, 2013 Posted January 10, 2013 ??? (vl-load-com) (defun c:FOO ( / filepath file) (setq filepath (vl-filename-mktemp "[color=red][i]foo.txt[/i][/color]")) (setq file (open filepath "w")) (write-line "@echo off" file) (write-line "C:\Program Files\7-zip\7z.exe C:\xampp\htdocs\out\unique-ID#.zip c:\temp\unique-ID#.*" file ) (close file) (startapp "notepad" filepath) (princ) ) Quote
Bill Tillman Posted January 10, 2013 Author Posted January 10, 2013 That's cool and I will examine that a little closer when time permits. For now, here is what I came up with and she's working quite well. (setq f (open "C:/0/zipmeup.bat" "w")) (write-line "@echo off" f) (write-line (strcat "\"C:\Program Files\\7-Zip\\7z.exe\" a C:\\xampp\\htdocs\\out\\" uniqueID ".zip c:\\temp\\" uniqueID "* -x!*.bak") f) (close f) (startapp "C:/0/zipmeup.bat") Quote
Bill Tillman Posted January 10, 2013 Author Posted January 10, 2013 Ooops, my bad. When I tested this I only tested that the batch file was being written correctly and then I executed it manually. Of course it all went well. But while the LISP program is running, the drawing file itself must be open and the 7-zip program reports back that it can't include the file in the archive because it's in use by another program. So I think, great, I will close the drawing file...but then of course I'm faced with the same old nemesis of mine which is once the drawing file is closed, LISP is no longer loaded. Damn, why didn't they think of this at AutoDesk. There are countless times I need to close the drawing file but then have the LISP file do a couple more tasks before it closes itself. I will have to go back to the drawing board on this one. UPDATE: Found this little tidbit about 7-zip....using the -ssw switch will allow it to use files opened by another process. Looks like we're home free. Quote
BIGAL Posted January 11, 2013 Posted January 11, 2013 Maybe a script (load "myzipper") close y (startapp "C:/0/zipmeup.bat") script myzipper2.....see below If you want to reopen the dwg again then it may need 2 scripts so it reopens the correct dwg part of myzipper would write that script or maybe as part of the BAT file acad.exe myolddwgname Quote
irneb Posted January 11, 2013 Posted January 11, 2013 Have you tried 7-Zip's command line switch to compress shared files? 7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] [<@listfiles...>] <Commands> a: Add files to archive b: Benchmark d: Delete files from archive e: Extract files from archive (without using directory names) l: List contents of archive t: Test integrity of archive u: Update files to archive x: eXtract files with full paths <Switches> -ai[r[-|0]]{@listfile|!wildcard}: Include archives -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives -bd: Disable percentage indicator -i[r[-|0]]{@listfile|!wildcard}: Include filenames -m{Parameters}: set compression Method -o{Directory}: set Output directory -p{Password}: set Password -r[-|0]: Recurse subdirectories -scs{UTF-8 | WIN | DOS}: set charset for list files -sfx[{name}]: Create SFX archive -si[{name}]: read data from stdin -slt: show technical information for l (List) command -so: write data to stdout -ssc[-]: set sensitive case mode [color=red]-ssw: compress shared files[/color] -t{Type}: Set type of archive -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options -v{Size}[b|k|m|g]: Create volumes -w[{path}]: assign Work directory. Empty path means a temporary directory -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames -y: assume Yes on all queries Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.