Creating and editing script palettes and scripts
Document scripts can be created, saved, and executed within a Vectorworks file. Scripts must be nested in script palette folders. Use the Resource Manager to manage script palettes folders as well as individual document scripts.
Creating scripts
To create a script:
From the Resource Manager, click New Resource, select Script, and then click Create. Alternatively, from the Resource Manager, select Scripts from the list of resource types on the tool bar, and click New Script.
Scripts must be placed in a script palette folder. Do one of the following:
If script palettes exist in the file, the Select Script Palette dialog box opens; select the palette to add the script to and click Select, or click New Palette to create a palette.
If no script palette exists, a new palette is created automatically; enter a name for a new palette.
The Assign Name dialog box opens. Enter the name of the script.
The Script Editor opens to begin a script editing session. Select the script language for the script: Python Script or VectorScript. The editor provides a basic authoring environment for script development and maintenance. Its features allow you to create, edit, and compile scripts, browse available functions, view errors, and perform other tasks associated with creating scripts. The script editor offers code hinting functionality to help reduce errors when scripting, including bracket matching, call tips, and auto-completion. Scripts are limited to 32,001 characters. For detailed developer-oriented documentation related to Python and VectorScript, please navigate to developer.vectorworks.net.
Click to show/hide the parameters.Click to show/hide the parameters.
Parameter |
Description |
Editor menu
|
|
Procedure |
Opens the Procedures dialog box, which lists all the available script functions/procedures by category and provides a prototype as well as a brief description of what operation is performed by the function/procedure. The list serves as both a reference and a means of building the code by pasting the relevant function/procedure into the editor. Enter text in the search box to filter the list. Select the procedure or function and click OK to add it to the current line of the script editor. |
Criteria |
Opens the Criteria dialog box, for automatically defining selection criteria in a script (see The Criteria dialog box) |
Tool/Attribute |
Opens the Custom Tools dialog box, for saving the current tool and attribute state information into a script (see Creating custom tool/attribute scripts) |
The Parameter command provides access to a plug-in objects’ parameter list for editing, when working on the script of a plug-in (see Plug-in definition) |
|
Text File |
The Text File command allows script source code to be imported from external text files |
Compile Script
|
The Compile Script button allows a script to be compiled directly from the Script Editor without the need to execute the script. If errors exist within the script that prevent successful compilation, they will be displayed and can be resolved without the need to exit the script editor. While compiling VectorScripts reports all errors in the script code, compiling Python scripts reports only the syntax errors. For example, an undefined variable is not reported as an error for Python scripts, because this type of error is determined only during script execution. As a result, Python scripts report most errors when executed. |
Find/Replace |
Opens the Find and Replace dialog box to search the current script for text and optionally replace an instance or all instances of a word |
Undo/Redo |
Undoes the last action, or redoes the just completed undo action; the same keyboard shortcuts that activate the main Vectorworks Undo command (Ctrl+Z Windows, and Cmd+Z Mac) and Redo command (Ctrl+Y Windows, and Cmd+Y Mac) activate the functions in this dialog box |
Show/Hide Special Characters |
Toggles the display of the space, tab, and CR/LF (line break) symbols |
Language |
Select Python or VectorScript for the script language |
(Python scripts only) |
Opens the Script Options dialog box, which lists folders (environment paths) where imported modules are located, for Python scripts that require external libraries. This dialog box can also be accessed from Tools > Plug-in > Script Options. Add: Select a folder location to add it to the list. Remove: Deletes the currently selected folder location. Open Folder in OS: Displays the contents of the selected folder in Windows or Mac. |
Scripts can be edited, renamed, deleted, exported, imported, moved, and executed from the Resource Manager.
Editing scripts
To edit an existing script:
From the Resource Manager, right-click on the resource, and select Edit from the context menu. Scripts are nested in script palette folders.
The Script Editor opens, displaying the script source code. See Creating scripts for a description of the Script Editor.
Encrypting scripts
Command |
Path |
Encrypt Script |
Tools > Plug-ins |
Encrypt a script to prevent editing.
To encrypt a script file:
Select the command.
The Choose Script File dialog box opens.
Locate and select the script file to encrypt.
Click Open.
The Save Encrypted VectorScript Code Document dialog box opens.
Enter a new name for the script, and then select the location for saving the file.
Click Save.
The script is saved in an encrypted format.