Tutorial : Automation with scripts (Part-3)

Commands that control AutoCAD scripts

Hi Everyone,

I hope you are all having an idea of what scriptys are and must have created some scripts.

For the friends who have just joined the series here are the links for previous posts :

Part - 1         Part - 2

Today, We shall discuss command that control the AutoCAD scripts.
Actually, there are a only a few commands that relate specifically to scripts. In fact, these commands are of absolutely no use for any other purpose.

Script.
The Script command (1) loads a script file; and (2) immediately begins running it. Use it like this:

      Command: script
      Enter script file name <C:\Users\Abhay_2\Documents\Drawing1.scr>:Filename

Remember to turn off (set to 0) the FileDia system variable, so that the prompts appear at the command line, instead of the dialog box.


RScript.
This is short for "repeat script," this command re-runs whatever script is currently loaded in AutoCAD. A great way to creating an infinite loop. There are no options:
    Command: rscript
Resume.
This command resumes a paused script file. I pause a script file by pressing the Backspace key. Again, no options:
    Command: resume
Delay.
This command is used to create a pause in a script file. Delay command should be used along with a number.
The number specifies the pause in milliseconds, where 1,000 milliseconds equal one second. The minimum delay is 1 millisecond; the maximum is 32767 milliseconds, which is just under 33 seconds. While I could use Delay at the 'Command:' prompt, that makes little sense; instead, Delay is used in a script file to wait while a slide file is displayed or to slow down the script file enough for humans to watch the process, like this:
    ; Pause script for ten seconds:
    delay 10000
In addition to these four script-specific commands, there are some special characters and keys. The most important special characters are invisible: both the space and the carriage return (or end-of-line) represent me pressing the Spacebar and Enter key. In fact, both are interchangeable. But the tricky part is that they are invisible. Sometime, I'll write a script that requires a bunch of blank space because the command requires that I press the Enter key several times in a row. AttEdit is an excellent example:
; Edit the attributes one at a time:  
attedit    1,2
How many spaces are there between 'attedit' and the coordinates '1,2'? I'll wait while you count them ...
For this reason, it is better to place one script item per line, like this:
    ; Edit the attributes one at a time:
    attedit


    1,2
Now it's easier to count those four spaces, since there is one per blank line.

; (semi-colon).
To insert comments in a script file. AutoCAD ignores anything following the semi-colon.

' (apostrophe).
Scripts can be run transparently during a command. For Example, simply prefix the Script command to run a script while another command is active, like this:
    Command: line
    Specify first point: 'script
    >>Script file: filename
The double angle bracket >> is AutoCAD's way of reminding me that I've got two commands on the go. In fact, all four of AutoCAD's script-specific commands are transparent, even 'Delay. That lets me create a delay during the operation of a command.

* (asterisk).
There is one special case where the asterisk gets used. When I prefix the VSlide command with the *, AutoCAD "pre-loads" it to provide faster slide viewing performance:
    *vslide
Backspace
is the key I already mentioned for pausing a script file.

Esc
stops a script file dead in its tracks; use the RScript command to start it up again from the beginning


No comments:

Post a Comment