Scripting

VisualApplets offers a scripting interface with which you can manage your designs via the scripting languages Tcl or Python.

Scripting in Python or Tcl provides the power of a programming language while being easy-to-learn. Using it can be as simple as calling commands in a shell. At the same time advanced programming techniques can be used to set up sophisticated processing schemes. 

Combining VisualApplets with the power of a scripting language allows an enormous increase of productivity.

You can:

  • Automatize the creation of designs:

    Use scripts to assemble components of your design controlled by parameters. Set up libraries of processing pipelines and create bunches of different designs automatically.

  • Automatize the simulation of designs:

    Scripting allows you to define very extensive simulation runs: You can, for example, specify series of simulation runs over thousands of images stored somewhere in your file system. Or, you can define various simulation runs where different sets of design parameters are used for simulation.

[Tip] Documentation

You find information on how to use the VisualApplets Scripting Console and an extensive command reference of Python and Tcl commands at Overview of Scripting .

[Note] Availability

The VisualApplets scripting feature is part of VisualApplets Expert.

To use scripting, you need to hold either an Expert license or the VisualApplets 4 license.

Script Collection

You can make the individual procedures in your Python and Tcl scripts available directly in the VisualApplets GUI.

VisualApplets allows you to define a script collection (library) containing sorted commands that each call a specific procedure in a specified Python or Tcl script. The commands are graphically available directly on the VisualApplets GUI. As soon as you start a command via mouse click or per drag&drop, the underlying procedure is carried out. You can monitor what happens in the Scripting Console of the VisualApplets program window.

You can define a script collection either in a graphical way, using the VisualApplets GUI, or creating/editing an XML file that defines the script collection.

As all information regarding your script collection is stored in XML files, you can use version control systems not only for the individual Python or Tcl scripts, but also for the structure and content definition of your script collection.

The commands are available in the Script Collection pane:

Script Collection in the VisualApplets program window

Figure 166. Script Collection in the VisualApplets program window


[Tip] Documentation

You find information on how to use the VisualApplets Scripting Console and an extensive command reference at Creating Script Collections (Script Libraries) and at Tcl Command Reference and Python Command Reference .

[Note] Availability

The VisualApplets scripting feature is part of VisualApplets Expert.

To use scripting, you need to hold either an Expert license or the VisualApplets 4 license.

Tcl Export

VisualApplets allows you to export VisualApplets designs as Tcl script (*.tcl).

You can use the script format for the following purposes:

  • revision control

  • comparing versions automatically (by creating "diffs")

However, some information is lost during export to Tcl script. Therefore, you should always save your design in *.va format. The Tcl file is not qualified to be used as the primary data format.

[Note] Save Design in *.va Format

Use the *.va file format as primary data format for your VisualApplets designs.

The Tcl script does not contain the full design information.

Exporting to Tcl

The following information is lost during export to Tcl script:

  • The local modifications you made in a user library element instance (to adapt the instance to the surrounding design) are lost. If you re-import a Tcl script into VisualApplets, the instance is inserted as a fresh copy of the user library element. The content of the instance in your design has not been saved in Tcl.

  • The content of info boxes is kept in Tcl format. However, the formatting of info boxes is lost.

You should always save your design in *.va format, too. The Tcl file is not qualified to be used as the primary data format.

To export your design to a Tcl file (*.tcl):

  1. From the menu, select FileExportDesign to Script....

    Exporting a Design

    Figure 167. Exporting a Design


  2. Select a location for the *.tcl file containing your design, and click on Save.

Now you can check in the Tcl file into your version control system, or find differences between different versions of the design using a "diff" tool.

Importing from Tcl

To import your *.tcl design file into VisualApplets:

  1. From the menu, select FileImportDesign from Script....

    Importing a Design

    Figure 168. Importing a Design


  2. Browse to the location of the *.tcl file containing your design, and select the *.tcl file.

  3. Click on Open.

Now your design is opened in VisualApplets, and you can

  • continue editing your design within VisualApplets,

  • save your design file as *.va file.

[Warning] Always use *.va File Format as Primary Data Format

Always use the *.va file format as primary data format for your VisualApplets designs.

Never use the Tcl script format as primary data format, as the Tcl script does not contain the full design information.