Applies to : Vista 26.9 and later

Macros and Scripts

Vista allows you to create scripts to automate tasks and edit your diagrams.
Scripts are written in Javascript using the internal object model.
Learn more about the object model in the Vista Developers Guide section.

The Macro Panel features an advanced code editor with syntax highlighting, error tracking, and intelligent member insertion to make scripting as intuitive and efficient as possible.

Key Features

1. Code Editor and Execution

  • Write and Run: You can write standard JavaScript code directly in the integrated editor. Click on the Execute button to run your script against the current project context.
  • Error Highlighting: If your script fails during execution, the editor will automatically pinpoint the exact location of the error. A red error indicator will appear in the editor's left margin, helping you debug your code quickly.

2. Managing Scripts

  • Save Scripts: You can easily save your current script by clicking the Save button. Scripts are included in your Vista diagram file.
  • Open Scripts: Click the Open button to display a dialog listing all the scripts currently saved in your document. Select a script from the list to load its contents back into the editor.

3. Importing Modules

The Vista application provides built-in libraries and modules that you can leverage within your scripts.

  • Click on Import Module (Importer un module) to open a catalog of all available known modules (KnownLang).
  • The dialog displays the name and description of each available module.
  • Selecting a module will automatically insert the correct ES6 import statement (e.g., import {XXXX} from 'lib') into your code, giving you instant access to its functionalities.

4. Inserting Members (Methods & Properties)

You don't need to memorize the entire API. The Insert Member feature acts as an interactive reference guide.

  • Click the Insert Member button to open a non-modal floating window. You can keep this window open alongside your editor.
  • Quick Insertion: Double-click any method or property, or select it and click Insert, to instantly inject the member's name into your script at your current cursor position.

Tip

Keep the Insert Member dialog open on the side of your screen while writing complex scripts. Since it is non-modal, you can click back and forth between the editor and the dialog to rapidly assemble your code!