Jump to content
Sign in to follow this  

$include is confusing me

Recommended Posts

I have written a script named door.vsm using the script editor

I want to call this script from another script named create.vsm

When I run the create.vsm script I have a dialog box with a check box. If the check box is checked I want $include to run the door.vsm script.

Does anyone have a simple example on how to do this properly?

Share this post

Link to post

A couple of things.

1. Don't name either of the scripts Door. There can only be one object type or command with a given name in a VW document. Also don't name your classes of layers door as the Door object won't work.

2. The {$INCLUDE} directive just brings code into the script from an outside text document. The function or procedure you want to run needs to be written in the include file just like if you were writing it as part of the main procedure. Depending on what you are doing, you might need to use mulitple includes as the constant and variable declarations need to be included in the correct parts of the main routine as does the actual code.

If the checkbox in the dialog box returns a boolean variable then something like:

VariableInMainScript := FunctionFromIncludFile;



would work to call it.

{$INCLUDE} is just a way to break up the code into different files, not a way to call external procedures/functions.

Share this post

Link to post

Ok I finally got this Include thing working! Now I just have to make sure I use a common file path so it will work on multiple computers.

I created the following test script. The script creates two rectangles. All the variables are declared and assigned values in the main script. The first rectangle is created in the main script. The $Include directive is then used to call the file named "rectb" which only contains the code to draw the second rectangle. The main script "includes" the code from "rectb" then proceeds to complete the remaining code in the main script.

The Main Script:

Procedure CreateRect;


X01, X02, Y01, Y02: REAL;

X03, X04, Y03, Y04: REAL;










Rect(X01, Y01, X02, Y02);

{$INCLUDE Macintosh HD:Users:MyName:Desktop:MiniDrive Sync:Completed Tools:Include Test:rectb}



The file "rectb" simply Contains the Following:

Rect(X03, Y03, X04, Y04);

I'm guessing that as the long as the code is written correctly and compiles successfully then I can break it into as many pieces as possible. I just have to make sure that all the little pieces are called in the correct order. I'm assuming it doesn't matter where variables are declared as long as they are declared in the correct position in the code. Are my assumptions correct?

Share this post

Link to post

Unfortunately, your assumptions are not correct.

All global constants and global variables must be defined at the top of the main procedure.

Local variables (those defined within a function or procedure block) can be defined anywhere.

How big do you expect the overall code to be? Unless you are looking at a very large project, I would probably do a copy/paste of the include code prior to publishing a shipping version. It will save you a lot of tech support in the long run.

You might also want to check out the ability to do a relative location for the include file. Using this, it will look for the include file in the same place as the original script. Makes it easier since the user can then install in the Plug-ins folder in either the Vectorworks or the User folder.

Share this post

Link to post

well some of the code I've created in the past has had a problem due to file size. One of the codes I am working on for my office draws a door in elevation. the users have the option to choose what type of door, as well as, the type of panels the door has. I'm always modifying and adding to this code. Depending on what I am adding I create small test scripts (like the one above) so that I do not have to work within the main script. After I get the piece of code working correctly I add the code to the main script.

I fear that one day, like in the past, I will end up adding too much to the Main script and it will no longer run in vectorworks. So I think the include directive will help me to create a new type of organization that will allow me to keep the main script much much smaller in size. The main problem I see with this organization is getting the file paths correct. One missed link will screw up the entire script.

Now that I am beginning to understand the Include directive I want to start learning how to create Plugin Objects that will make the objects created by my script interactive via the Object Info Pallete. any good clean examples on that?

Share this post

Link to post

The code size limitation is in the VS editor, not in the size of the code itself.

One way around this is to use the $INCLUDE to include all of your code from an external text editor. TextWrangler or BBEdit both work well on the Mac. TextWrangler is Free.

Orso B. Schmidt has written some free plugins for TextWrangler that will let you send your code directly to VW for testing.

Check out




for more information on external editors.

As for sample PIOs. check out some of the freebies available from vectordepot or the examples from NNA available on this page:


The brief explaination of a PIO is that it is an object with a Parameter Record attached. Those parameters show up in the OIP. They work as constants in the program and you use them in the code just like constants, but put a P (letter P) before the name of the parameter (i.e. PParameterName). Use SetRField to store a changed value back to the parameter record.

Edited by Pat Stanford

Share this post

Link to post

I've downloaded the sample Rectangle Plugin Object.

The archive file contains the following:

Simple Grid.vso


i was able to open the file simplegrid.vss in textwrangler. I have tried to compile the simplegrid.vss code in vectorworks but I get an error telling me that specific identifiers are not declared.

How am I suppose to correctly load these files into vectorworks?

Share this post

Link to post

The VSS file is just a version of the code that is readable in a text editor. The vso is a Vectorworks Plug-in object.

Put the vso file into the following path

Users:You:LibraryApplication Support:Vectorworks:2009: Plug-ins

and then restart VW.

Go to Tools:Scripts:Vectorscript Plug-in Editor.

Scroll down until you see Simple Grid and select it.

Click on the Scripts button to see/edit the script.

Click on the Parameters button to see/edit the parameters.

Share this post

Link to post

Thanks Pat!

check out my first Plugin Object.

See any problems?



l,Offset,PanOffset,PanNumber,X01,Y01,A,B,C,D,E : REAL;

M01,M02,M03,M04,i :INTEGER;

result : BOOLEAN;

objname : STRING;

oh,rh,wh : HANDLE;


{ retrieve custom object information }

result:= GetCustomObjectInfo(objname,oh,rh,wh);

{ if object information was successfully retrieved }


{ retrieve parameters }


X01 := PWIDTH;

Offset := POFFSET;

PanOffset := PPANOFFSET;

PanNumber := PPANNUMBER;


{ B is equal to the size of the panel }


{ C is the point relative to the height (Y01) }


{ draw Shutter }









{ draw Panels }














until i=PanNumber;





Share this post

Link to post

I don't see any real problems.

Since you don't change any of the parameters in the script, you don't need to assign them to variables. You could just replace every instance of PanNumber with PPanNumber for example.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...