NEXT, PLEASE (n.scr)

All the drawings for the project have been completed and checked and now need to be plotted. You have a fast inkjet plotter with roll-feed but you have to spend the next two hours at the machine going from drawing to drawing, sending plots to the plotter. Then you're going to spend another two hours trimming and collating the drawings.

Or you can use an intelligent script file like N.SCR that will go from drawing to drawing for you, sending plots to the plotter while you trim and collate the drawings as they come off the plotter. Besides plotting, it can be used for anything that needs to be done to a number of drawings such as exporting to DXF or redefining layers to a new layering standard.

N.SCR takes advantage of AutoLISP's ability to be typed in at the command prompt by supplying lines of code to the command line in the same way that script files normally supply commands and other information to the command line. The reason N.SCR is not N.LSP is that an AutoLISP program stops executing when a drawing is exited but a script file continues on. By incorporating AutoLISP code into a script file, you get the best of both worlds; the data processing power of AutoLISP and the script file's ability to change drawings.

THE LISTING.

The file has a large description because the script file is not static - users will need to make changes that will enable it to carry out the task at hand and they need to be informed of how to go about it. The description also has a few tips and tricks to make its use easier.

The first working line of the file is AutoLISP code that checks the length of the string stored in the Users1 Setvar. If it is greater than zero then there is a value stored in Users1 and the IF's then-expression on the next line converts the value to an integer and stores it in the Auxstat Setvar. If the string length was zero then there was no value meaning that the script file had only just started. This will cause the IF's then-expression to run, ensuring that Auxstat is zero. The parenthesis on the next line closes off the IF that was started on the first line.

The value stored in Auxstat is then incremented by 1. Auxstat is an undocumented Setvar capable of storing integers up to 32757. It is not very good at storing them and occasionally is reset to zero. For this reason, the next line converts the integer to a string and stores it in the more stable Users1 Setvar.

The seventh line checks the value of the Dbmod Setvar and if anything other than zero (meaning the drawing has been modified) will run the Qsave command, saving the drawing.

The eighth line opens a file called dirfile for reading. The ninth line read lines from dirfile, the number of lines being the number in Users1 (converted from a string to an integer). Each line will be stored in variable F3, each new line overwriting the previous value of F3. When the required number of lines have been read, the value of F3 will be the name of the next drawing file to open. The tenth line closes the dirfile file.

The use of an asterisk on a line by itself in dirfile provides a pause facility to break the job into manageable chunks. The eleventh line will check if an asterisk has been read in and if so will run the code on the next line which displays an alert box with the message that the script has been paused and also the value of Users1. The command function is called with an apostrophe to create an error that will crash the script. The thirteenth line closes the IF.

The fourteenth line checks to see if F3 has a value and if not (the end of dirfile has been reached), will display an alert box with the message that the end has been reached. The apostrophe command is called to crash the script.

The fifteenth line is simply the Open command (no AutoLISP) and the sixteenth line extracts the value of F3 (the next drawing filename) and passes it to the waiting Open command. After the next drawing has been opened, the value of Auxstat is saved to Users1.

The following three lines are commented out with semi-colons (;) and this is where you would put the command script for your task (without the semi-colons). You will need to work out what needs to go in there.

The last line is the script command, Rscript, that starts the script again. If you want to use N.SCR to simply jump to the next drawing and you do the work then comment it out by putting a semi-colon at the beginning of the line.

Using N.SCR

Run it by invoking AutoCAD's Script command and supplying N to its file request, either at the command line or in the file dialogue box. The file dialogue box expects it to be in the current working directory but entering it at the command line will search the support directories.
 

©1996-2001 ZOTO Technologies