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

Active Script console


"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 we fully agree with what's written here). Tcl is a command language, i.e., it works best when what you're mostly doing is passing commands for execution. It is arguably worse in its "programming language" aspects, but still, it's also a programming language. Although Tcl really shines as a command language, you still have all necessary programming tools, such as conditionals, loops and user-defined procedures.

Another shiny facet of Tcl is its C API which is very easy to plug in without any wrapping whatsoever. And, finally, Tcl is natively used by OpenCascade, so we are a little bit biased in the choice.

Each command in Analysis Situs is formulated in the following fashion: verb minus noun, e.g.: offset-shell, start-contour, print-summary, etc (minus is better than underscore!).

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.


Hotkey Effect
<Enter> Execute current line.
<Shift> + <Enter> Insert empty line after the current line.
<Ctrl> + <↑> Zoom in.
<Ctrl> + <↓> Zoom out.
<Ctrl> + <Space> Replace all backslashes in the current line with forward slashes.


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.

  # 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