./features/active script
Download Features Source code References Ask for support

Active Script console

"Embrace scripting."
"Drive or Script." (Alexis S.)

Most functionality of Analysis Situs is available through scripting. We use Tcl language which we appreciate for its clearness and pure functional paradigm. Each command in Analysis Situs is formulated in the following fashion: verb minus noun, e.g.: offset-shell, start-contour, print-summary, etc.

For scripting, we have a dedicated panel where you write your commands and execute them. This panel is a bit special because it is not a usual one-line prompt, but rather the script editor where each line can be executed individually (one could have met a similar concept in the Maple sheets). Using this editor is advantageous for prototyping: you are free to insert commands to your sheet, erase unsuccessful trials, execute and re-execute lines in arbitrary order, and edit the script the way you like. We have named this concept as "Active Script" which, we think, is a more powerful paradigm than a classical command-line prompt.

Pressing the <Enter> key executes the current command at the position of a cursor. To insert a new command between the two existing ones, use <Ctrl+Enter> key combination. You may save the scripts prepared in the Active Script editor to file and execute them later with the Tcl native source command, e.g.:

source <path-to-script>

Some example scripts can be found in the "scripts" subdirectory of Analysis Situs. This directory is accessible via ASI_TEST_SCRIPTS environment variable in the Active Script console.

When specifying the path for the source command you can use both forward and back slashes.

You can also execute Tcl scripts in the batch mode without GUI.

Examples

Build a prismatic block

The following procedure creates a prismatic block.

proc build-block {L0 B0 a1Deg a2Deg} {
  set Pi 3.1415926535897931

  # Design variables.
  set a1 [expr $a1Deg.*$Pi/180.]
  set a2 [expr $a2Deg.*$Pi/180.]
  set V1x [expr -$L0/2 - tan($a1)*$B0/2]
  set V1y 0
  set V2x [expr $L0/2 + tan($a2)*$B0/2]
  set V2y 0
  set V3x [expr $L0/2 - tan($a2)*$B0/2]
  set V3y $B0
  set V4x [expr -$L0/2 + tan($a1)*$B0/2]
  set V4y $B0
  set d 20.

  # Build geometry.
  make-point V1 $V1x $V1y 0.
  make-point V2 $V2x $V2y 0.
  make-point V3 $V3x $V3y 0.
  make-point V4 $V4x $V4y 0.
  fit

  # Build topology.
  make-edge e1 -p1 V2 -p2 V1
  make-edge e2 -p1 V1 -p2 V4
  make-edge e3 -p1 V4 -p2 V3
  make-edge e4 -p1 V3 -p2 V2
  make-wire w e1 e2 e3 e4
  make-face f -w w

  # Make prism.
  set-as-part f
  offset-shell -$d -simple -solid
}

Convert BREP to STEP

The following code visits all BREP files in a directory and converts them to STEP:

set workdir   MyWorkDir
set targetdir MyTargetDir

# Get all BREP files available in the input directory.
set filenames [glob -directory $workdir -- "*.brep"]

notifier -init

foreach inFilename $filenames {
  puts "Next file: $inFilename"
  set basename [lindex [file split $inFilename] end]
  set basename [file rootname $basename]

  puts "Target output file: $targetdir/$basename.stp"
  load-brep $inFilename
  save-step "$targetdir/$basename.stp"

  notifier -step
}

notifier -finish