Recording and playing actions in BricsCAD

Commands

RECSCRIPT, STOPSCRIPT, SCRIPT

Recording actions in BricsCAD

  1. In a new drawing, launch the RECSCRIPT command or from the Tools menu select Record Script....

    The Record Script dialog box opens.

  2. Enter a file name for the script. For this tutorial, enter border and then click Save. The border.scr script file is created.
  3. Notice that the Record Script dialog box is closed and the Command line prompt is available, and you can enter the commands you like.

    For example:

    1. Launch the RECTANG command.
      : RECTANG
      Select first corner of rectangle or [Chamfer/Fillet/Rotated/Square/Elevation/Thickness/Width of line/Area/Dimensions]: 0,0
      Other corner of rectangle: 36,24
    2. Launch the ZOOM command.
      : ZOOM
      Zoom [zoom In/zoom Out/All/Center/Dynamic/Extents/Left/Previous/Right/Scale (nx/nxp)/Window/OBject] <Scale (nX/nXP)>: E
    Note: You can use the mouse to pick points in the drawing during commands while recording. BricsCAD records the pick points as x, y coordinates.
  4. Launch the STOPSCRIPT command whenever you want to stop the recording.

Playing a script file

You can run the script with the SCRIPT command as follows:

  1. Start a new drawing with the NEW command so you can see the effect of the script.
  2. Enter the SCRIPT command.
  3. The Run Script dialog box opens. Choose border.scr and click Open.

The script instantly draws the rectangle and then zooms the drawing to the extents of the newly drawn border.

Writing Scripts by Hand

While BricsCAD has commands for creating and running scripts, it has no command for editing them. If you want to change the coordinates used by the RECTANG command, you have to edit the script file with a text editor, such as Notepad in Windows, Text Edit in Linux, or TextEdit in macOS.

  1. Open the border.scr file in a text editor.

    Notice the commands and options that you entered during the script recording session:

    Change the commands as below:

    1. Change the size of the border to 18×24. Edit the "36,24" text, replacing it with "18,24".
    2. Add the command for placing the rectangle on a layer named "Border" and colored red:
      1. Place the cursor in front of "rectang", then press Enter to make an empty line.
      2. Enter the following text:

        -layer

        make

        border

        color

        red

        ▄ <-- One blank line

        ▄ <-- A second blank line

    3. Make sure you include two blank lines. These act like pressing Enter during commands. The file should now look like this:
  2. Save the file.
  3. Return to BricsCAD and start a new drawing.
  4. Use the SCRIPT command to test that the border.scr file is operating correctly. You should see a red rectangle.

Script Commands and Modifiers

There are four commands that relate specifically to scripts. In fact, these commands are of absolutely no use for any other purpose. In addition, BricsCAD has the RECSCRIPT command for recording scripts, as described earlier in this chapter.

The four basic commands are:

SCRIPT
The SCRIPT command performs double-duty: (1) it loads a script file and (2) immediately begins running it.
Note: 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
Short for "repeat script", this command reruns whatever script is currently loaded in BricsCAD. A great way to create infinite loops.
RESUME
This command resumes a paused script file. Pause a script file by pressing the Backspace key.
DELAY
To create a pause in a script file without human intervention, use the DELAY command along with a number. The number specifies the pause in milliseconds, where 1,000 milliseconds equal one second.
Note: The minimum delay is 1 millisecond. The maximum is 32767 milliseconds, which is just under 33 seconds.

The DELAY command 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.

SPECIAL CHARACTERS

In addition to the script-specific commands, there are some special characters and keys.

Enter -- (space)

The most important special characters are invisible: both the space and the carriage return (or end-of-line) are the equivalent to when you press the Space or Enter keys. In fact, both are interchangeable. But the tricky part is that they are invisible. Sometimes, when you write a script that requires a bunch of blank space because the command requires that you press the ENTER key several times in a row. The ATTEDIT command 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?

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 is easier to count the four spaces, since there is one per blank line.

Comment -- ;
The semicolon lets you insert comments in a script file.
Note: BricsCAD ignores anything following the semicolon.
Transparent -- '
Scripts can be run transparently during a command. Simply prefix the SCRIPT command with an apostrophe to run a script while another command is active, like this:
: LINE
Start of line: 'script
Script to run: filename

All four of BricsCAD's script-specific commands are transparent, even DELAY, which lets you create a delay during the operation of a command.

Pause -- Backspace
Represents the key mentioned earlier for pausing a script file.
Stop -- esc
Stops a script file dead in its tracks; use the RSCRIPT command to start it up again from the beginning.