I've often seen newer VectorWorks users (or even experienced ones) post questions like,
Well, no one has time to read the manual to expose a completely new aspect of the program, so in this post I'll try and condense it a bit. There are essentially 3 ways to use a VectorScript from within VectorWorks:
Run it using the "Run VectorScript..." command;
Create a document script and run it from a script palette;
Turn it into a plug-in menu command, or VSM;
Let's address these methods one by one, but before we do, let's make sure everybody agrees on what "a VectorScript" is. A VectorScript (VS hereafter) is a text listing, and it's really not picky about formatting or capitalization. Some people (like me) use a lot of tab-indenting to make the VS easier to read by other programmers, but VectorWorks really doesn't care about this when it's running a VS. What you do need to know is that a VS always starts with a PROCEDURE call and ends with a RUN call. So, your VS listing (which will become your text file or document script or whatever below) will always look like this:
(followed by a whole lot of programmer-ese, sometimes hundreds of lines!, finished up with)
It is these two lines of code (and of course everything in between) that constitutes "a VectorScript", and this is what needs to be cut-and-pasted from these forum pages into a text file or VS Editor window to make it into a useable form.
Now, let's look at the three methods enumerated above:
Run a VectorScript using "Run VectorScript..."
This one is the easiest. Copy the VS from where you got it, and paste it into a file using a text editor. Instead of saving it with a .TXT filename extension, save it with a .VS extension. Put it somewhere in your computer's file system where you won't lose it. When you want to use the script, just run Tools:Scripts:Run VectorScript... and you will see a standard open dialog. Find your script and click the Open button at the bottom of the dialog. The script will run.
This method has the advantage of being easy and quick, and is the easy way to make a VS available to any VectorWorks file.
Create a document script and run it from a script palette
This method creates a script that is saved with a particular VectorWorks file. This can be useful is your script has been customized to work with just that file, or if you need the script to properly manage the file and you need to send the file to someone across the country, say.
To handle a script this way, use the Resource Browser and choose "VectorScript..." off the "New Resources in [filename]" menu. If you haven't already got a Script Palette created, VectorWorks will create one for you called "Palette-1" by default. You'll see a small "Assign Name" dialog asking you to name the script and when you click OK, you'll see the VectorScript Editor window. This is essentally a very simple text editor window. So, copy your script from wherever and paste it here. Click OK, and and the VS Editor window will close and you'll see a new "Script palette" which is just a small palette with your script name in it. Just double-click the script name to run it. You can have as many scripts as you want in a single script palette.
Turn a VS into a plug-in menu command
This method, which is somewhat more elaborate, allows you to add a script permanently to your workspace as a menu command. Use this when you have a script that you use all the time, one that you want to add a keyboard shortcut for.
To use this method, run the Tools:Scripts:Vectorscript Plug-in Editor... command. You'll see the VectorScript Plug-in Editor window. Click New. You'll now see the Assign Name dialog for plug-ins. Give your object a unique name and highlight the "Command" radio button if it's not already chosen. Click OK. You'll be returned to the main VectorScript Plug-in Editor window and the name you just entered will be highlighted in the list. Click the Script... button. You'll see the VectorScript Editor window (just as in the second method). Copy your script from wherever and paste it here. Click OK. Now you can optionally give this command a category using the "Category" button on the middle-right of the dialog. Click OK in the VectorScript Plug-in Editor window and you're done.
What you've just done is create a "VSM" file (a VectorScript Menu command plug-in) in your Plug-ins folder in your User Preferences folder. (Exactly where this folder is located is dependent on whether you're on a Mac or Windows machine, but it's where all your preferences are kept, also.)
Now that you've created this plug-in, you can add it to your workspace and assign it to a keyboard shortcut using the Workspace Editor command, just as you would any other command. It will show up in the Menus tab of the Workspace editor under the category you gave it (if any) in the VectorScript Plug-in Editor window. If you didn't categorize it, it will show up under the "Miscellaneous" category in the list at left.
OK, that's about it. Use your VectorScripts in good health!