mikeholmes Posted December 1, 2008 Posted December 1, 2008 I've written a autolisp that ask a few questions then prints a series of drawings. The problem is that it prints the last set of drawings instead of the set I want. Basically it is suppose to write PLOTJOB.TMP the make a script based on that file. Right now it seems to make the script and execute it then make the PLOTJOB.TMP file so that next time I run the script it plots the new .tmp version. Here is the source code: ; This allows you to plot a set of drawings all at once (defun c:PJ() (vmon) (setvar "sdi" 0) (prompt "PLOT A JOB") ; ; GET DRAWING PATH, JOB NUMBER, STARTING PAGE AND ENDING PAGE (setq path (getstring "\nEnter the path <J:\\142>: ")) (if (= (strlen path) 0) (setq path "J:\\142")) (setq job (getstring "\nEnter the job number: ")) (setq startpage (getint "\nEnter the starting page: ")) (setq endpage (getint "\nEnter the ending page: ")) ; ; GET PLOTTER COMMAND (setq plotter (getstring "\nEnter the plotter command <PCB>: ")) (if (= (strlen plotter) 0) (setq plotter "PCB")) ; ; SAVE DRAWING TO PREVENT PROBLEMS OPENING NEXT DRAWING (command "DEL" "C:\\DWG\\PLOTJOB.DWG") (command "SAVE" "C:\\DWG\\PLOTJOB") (command "DEL" "C:\\DWG\\PLOTJOB.DWG") (command "DEL" "C:\\DWG\\PLOTJOB.LOG") ; ; CREATE LIST OF DRAWINGS (setq dir (strcat "DIR/ON/B " path "\\" job "*.DWG >C:\\DWG\\PLOTJOB.TMP")) (command "shell" dir) (setq infile (open "C:\\DWG\\PLOTJOB.TMP" "r")) ; ; CREATE SCRIPT FILE (setq infile (open "C:\\DWG\\PLOTJOB.TMP" "r")) (setq outfile (open "C:\\DWG\\PLOTJOB.SCR" "w")) (setq inline (read-line infile)) (while (/= inline nil) (setq page (atoi (substr inline 6 3))) (if (and (>= page startpage) (<= page endpage)) (progn (write-line (strcat "OPEN " path "\\" (substr inline 1 ) outfile) (write-line plotter outfile) (write-line "\(setq logfile \(open \"C:\\\\DWG\\\\PLOTJOB.LOG\" \"a\"\)\)" outfile) (write-line "\(write-line \(getvar \"DWGNAME\"\) logfile\)" outfile) (write-line "\(close logfile\)" outfile) (write-line "CLOSE" outfile) (write-line "Y" outfile) ) ) (setq inline (read-line infile)) ) (close infile) (close outfile) (command "shell" "DEL C:\\DWG\\PLOTJOB.TMP") ; ; EXECUTE SCRIPT FILE (command "script" "C:\\DWG\\PLOTJOB.SCR") ) Quote
mikeholmes Posted December 2, 2008 Author Posted December 2, 2008 Also I tried breaking it up into two scripts at the form script area. If I do that and run them seperatly it works as expected but if I make the first half call a command to run the second half well it does what it does if it was one script. Quote
dbroada Posted December 2, 2008 Posted December 2, 2008 can you open then close the .tmp file before opening & closing the .scr one? (Not sure if it will help though) Quote
dbroada Posted December 2, 2008 Posted December 2, 2008 another thing. I know the AutoDesk plot routine used MDI mode but I always had trouble doing that. I couldn't get my files to sync properly. My own batch plot routine uses SDI mode, opening, plotting and not saveing each file before openning the next one. Again, no idea if that is contributory to your problem or not. Quote
LosGirk Posted May 16, 2014 Posted May 16, 2014 Dear dbroada, would you mind posting your code? I need to find an alternative to our plot routine, the program we've been using won't work in AutoCAD 15 with the error: ERROR: Commands cannot be nested more than four deep. I've got a post about it on the autolisp forum, but we haven't found a solution yet. Thanks Quote
BIGAL Posted May 16, 2014 Posted May 16, 2014 This post has a plot layouts by range http://www.cadtutor.net/forum/showthread.php?84430-Move-layout-Rename-layouts-Goto-layout so your script would be to just open dwg and load lisp rest happens. Open DWG1 (setq numlay 23)(setq numend 27) (load "plotrange") close N Open DWG2 (setq numlay 1)(setq numend 99)(load "plotrange") close N Open DWG3 (setq numlay 12)(setq numend 26)(load "plotrange") close N 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.