Running Scripts

Document scripts can be executed in a variety of ways.

Running Scripts from the Resource Browser

To run a script from the Resource Browser:

  1. From the Resource Browser, select the script palette containing the script to run.

  2. Double-click the script palette to open it.

  3. Alternatively, right-click (Windows) or Ctrl-click (Mac), and select Enter from the context menu to open the palette.

  4. Select the script to run. Select Run from the Resources menu, or right-click (Windows) or Ctrl-click (Mac), and select Run from the context menu.

Alternatively, double-click the script resource to run it or drag the script resource into the drawing area.

Running Scripts from the Script Palette

To run a script from a script palette:

  1. Select Window > Script Palettes and select the script palette containing the desired script.

  2. To open the script palette from the Resource Browser, select the script palette containing the desired script, and double-click to open it, or right-click (Windows) or Ctrl-click (Mac) on the palette, and select Open from the context menu.

  3. From the script palette, double-click the script to run it.

Running Scripts from Files

Some scripts may exist as text files only, if they were created in a separate text editor program or exported from the Vectorworks program. These scripts are not available from the Resource Browser.

  1. Select Tools > Plug-ins > Run Script (or File > Import > Import Script).

  2. The Choose Script File (or Import Script Drawing Document) dialog box opens.

  3. Select the desired script file and click Open to run the script.

Running Scripts from Worksheets

Often data for objects that you might want to report in a worksheet is not accessible with a worksheet formula. For example, landscape area objects contain planting rates and percentages for multiple plant types, but the information is stored internally. You could create a script to extract the planting rates for each plant type in an area, and then run the script from a worksheet using the RunScript function. When the function is used in a database header cell, the script returns values for each object that meets the specified criteria.

If the Vectorworks Landmark product is installed, several Python scripts are provided in the default content:

[Vectorworks]\Libraries\Defaults\Reports~Schedules\Landmark Schedules

Use these scripts as they are, or use them as samples to create your own scripts. To see examples of these scripts in a worksheet, select Tools > Reports > Choose Schedule, and open the preformatted schedule Landscape Area-Mass Planting.

For more information about extracting data from drawing objects, see Worksheet Functions.

If the Vectorworks Landmark product is not installed, samples and an article on this topic are provided in the developer-oriented documentation here:

developer.vectorworks.net 

Script Errors

If an error occurs during script execution, an alert dialog box opens.

To handle script errors:

  1. From the alert dialog box, click View Error Output.

  2. The Script Errors dialog box opens, displaying the nature of the error and the line where the error occurred.

  3. To edit the script, click Edit Script, or double-click a script line to edit that line. The Script Editor opens for making corrections to the script.

~~~~~~~~~~~~~~~~~~~~~~~~~

Creating Scripts

Editing Scripts

Using the Resource Browser

Creating a Script Palette

Using Scripts

 

vectorworks.net