You can find a list of the VectorWorks provided ready-to-use scripts, arranged according to industry, in the VectorWorks Toolkit Folder, which is easily accessed from the Resources palette.
When scripts are created either through the VectorScript Editor or automated script facilities, they can be placed in Scripts palettes. You can create multiple script palettes with unique names to sort your scripts. You may add your new scripts to that palette as well.
To use an existing script in a palette
To create your own scripts palettes
The Select Resource dialog box appears.
The Assign Name dialog box appears.
The new palette is created and placed in the current drawing.
With VectorWorks' built-in programming language, you can create a script that selects all objects that meet a specific set of criteria. For example, select all objects with solid black lines.
To create a Custom Selection script
The Custom Selection dialog box appears.
2. Enter the selection criteria.
Decide what type of script you want to create--one that Selects, Deselects, or Selects Only objects that meet your criteria.
3. Select the type of script option you want to create.
If you select Execute Immediately, then the visibility will be changed when you click OK. If you select Create Script, a name dialog will appear after you click OK. Name the script and it will be added to the default script palette.
The Database Criteria dialog box appears.
5. Select the desired criteria.
Use the series of pulldown menus to select each option.
The Assign Name dialog box appears.
7. Enter the name you want to give to this new script.
VectorWorks will place your new script in a Scripts palette. To use the script, double-click its name in the palette.
Note: Custom Selection works on the entire drawing, not just the active layer, unless you specify a layer in the criteria dialog. Items in groups are not affected.
With the Custom Visibility script, you can create scripts that hide or show all objects meeting a specific set of criteria, for example, all the walls in your drawing.
To create a Custom Visibility script
The Custom Visibility dialog box appears.
2. Select visibility criteria.
Decide what type of script you want to create--one that will Show, Show Only, or Hide objects that meet your criteria.
3. Select the type of script option you want to create.
If you select Execute Immediately, then the visibility will be changed when you click OK. If you select Create Script, a name dialog will appear after you click OK. Name the script and it will be added to the default script palette.
The Database Criteria dialog box appears.
5. Select the desired criteria.
Use the series of pulldown menus to select each option.
The Assign Name dialog box appears.
7. Enter the name you want to give to this new script
Your new script is placed in the Scripts palette. To use the script, double-click its name in the palette.
Note: Custom Visibility works on the entire drawing, not just the active layer, unless you specify a layer in the criteria dialog. Items in groups are not affected.
The Custom Tools/Attributes script allows you to record a variety of settings as you have set them in your current drawing. It is an automated way of creating a script that selects a tool, class, layer, constraint, attribute, and various other items. For example, you can use this feature to simultaneously select the rectangle tool, a blue pen, a red fill, a layer, and a class. When you run the script, all of these selections will be made for you and you can immediately begin to draw.
Note: Before you begin creating specialized scripts, it's a good idea to create a Defaults script. That way, you can easily return to your original settings at any time.
To create a Custom Tools/Attributes script
Set all your object attributes, including pen, fill, color, and pattern. Select your tool from the tools palettes. Set your layers and classes and any other features.
2. From the Organize menu, select Custom Tool/Attribute.
The Custom Tool/Attribute dialog box appears.
3. Select the settings you want the script to set by clicking on the checkbox to include a setting.
Of the items you set, click only those you wish to be set by the script. All other settings in the drawing will remain unchanged. If you want a tool, symbol, or constraint to be activated, select the appropriate box.
The Assign Name dialog box appears.
5. Enter the name you want to give the script in
VectorWorks will place your new script in a Scripts palette. To use the script, double-click its name in the palette.
You can create simple or even complex scripts using the VectorScript Editor. The VectorScript Editor is designed to provide an authoring environment for creating and editing VectorScript scripts. The Editor's features are designed to provide a basic but complete set of tools for this task.
The Editor contains a main editing window, as well as buttons which invoke procedures and functions, automated scripting facilities, and text import functions. The Editor's text window supports an ASCII text editing capability, similar to most basic text editors. Text may be cut, copied, and pasted.
The Create Resource dialog box appears.
The Assign Name dialog box appears.
If there are scripts palettes in the drawing, you will be prompted to select the palette to which the script is to be added.
If not, you will first be prompted to name a new palette and then to name the script.
5. Name or select the palette where you want to place the script.
The Assign Name dialog box appears.
The VectorScript Editor appears.
11. Double-click the script in the Scripts palette to run it.
To add procedures to the editor
The Procedures dialog box appears.
2. Click a Procedure Type (Chapter) and a Procedure.
To add selection criteria to the editor
This invokes a Database Criteria dialog as described in "Using Custom Selection".
2. Pull down the menu to select your criteria.
The criteria is entered into the editor.
This is the same as creating a Custom Selection script as described earlier in this chapter. See "Using Custom Selection" .
To add custom tool and attribute information to the editor
2. Check the appropriate boxes.
Remember that the current settings in your drawing will be executed as described in "Custom Tools/Attributes" .
The criteria is entered into the editor.
This is the same as creating a Custom Tool/Attribute script as described earlier in this chapter. See "Custom Tools/Attributes" .
To add imported text from other sources to the editor
The Select VectorScript File dialog box appears.
2. Select the desired text file.
All text in the file is entered into the editor.
Note: Double clicking the file will also add the text to the editor.
To view script errors that occur when running a script
2. Select the desired script from the file tree.
The VectorScript Editor is invoked.
4. Edit the script as necessary.
You can also invoke the VectorScript Editor by holding down the Alt (Windows) or Option (Macintosh) key and double-clicking the script in the Scripts palette.
As with any other scripting language, the best way to get started in VectorScript is to create and edit a basic script. In the world of programming, it is customary to begin with the Hello World script. The following steps are specific to that script.
A detailed description of the VectorScript language is available in the VectorScript language Guide on-line. A function and procedure reference is available through the on-line help in HTML format.
To create the Hello World script
2. Name the script Hello World.
3. Enter the following text in the Editor window.
5. The Hello World Script is added to a new or existing palette as described earlier.
If the desired palette is not currently displayed, use the Resources palette and select the desired scripts palette.
6. Double click Hello World in the palette.
If you have entered the program properly into the script editor, a message bar will be displayed.
If you encountered an error, you will need to return to the script editor and check for possible typographical errors. To do this, you can use a shortcut back to the editor. On Macintosh systems, double click on the script name while holding down the Option key; on Windows systems, double click on the script name while holding down the Alt key. Once you have re-entered the script editor, check your script for errors using the View Errors button and try running it again.
7. Re-enter the script editor and modify your script so that it appears as follows:
myMessage:= 'Hello again, world';
If you encounter an error, go back and check your script for any typos or other mistakes. One of the most common mistakes made by both novice and experienced VectorScript users is omitting one of the quotes around the message 'Hello again, world'. Another is forgetting semi-colons at the end of a line.
If you have proceeded to this point without any errors, try removing one of the quotes and executing the script to see how VectorScript responds. Resolving errors and debugging your scripts is an integral part of learning and using VectorScript, so you should get used to seeing an occasional error message and learn to use it as a guide to resolving the problem.