Jump to content
Developer Wiki and Function Reference Links ×

VW2024 and VectorScript


Recommended Posts

All,

 

I’m wanting to develop some plugins that can help our Residential Construction firm to reduce the time we are currently spending on repetitive tasks in our drawings.

 

At present, I’m curious as to whether the legacy information on VectorScript included in VectorScript Language Guide is still relevant for VW2024.

 

Conceptually, I’m trying to attack framing implementation, estimation, and work my way out from there, including IRC Building Code compliance.

 

If you have any input on logic or process, I’m all ears. Thanks for your time in advance.

 

Ryan Russell

Link to comment
  • Vectorworks, Inc Employee

Yes, Not much has changed about VectorScript. Most information from prior versions still applies to Vectorworks 2024.
The most current function reference is available on developer.vectorworks.net including a list of functions that are obsolete or deprecated.

If you haven't invested in Vectorscript development yet you may also want to consider developing in python.
The available functions supplied by Vectorworks in the same for Vectorscript and python but there is a larger external library available for python that you can use and more training materials available for python if you are just getting started.
Training and reference materials for pascal, which is the basis for Vectorscript, are a lot harder to find these days.

  • Like 1
Link to comment

@Ryan Russell  I wrote this up a few months ago for another user. It might be applicable to your question and @klinzey's comment about Python.

 

Quote

There are good and bad points to both Vectorscript and Python.

 

Vectorscript is based on Pascal, which was one of the most popular languages when I was in college in the mid 80s. So it was pretty easy for me to pick up VS coming from Pascal.  Pascal was designed as a learning language to teach programming. So it has a number of "features" that are designed to make it easier to learn, but that mean you have to type a little more. For example every "block" of code needs to be surrounded by Begin and End statements and every line has to end in a semicolon. But it is also a compiled language, so these types of "syntax" errors are found in the compile step (usually) and not when you try and run the program. A huge percentage of the early Mac software was written in Pascal. But it is no long a "popular" language, so almost any learning materials you can find will be from before 2000. The age doesn't matter since the language has not changed, but the availability of those resources could be an issue.

 

Python is a much more modern language, currently very popular, with a huge number of "libraries" available to perform almost any action you need. Vectorscript functions as a library inside of Python. So this means that Python can not do any more than Vectorscript inside of VW. But if you need to access data from the web, do sophisticated math or matrix operations, or even just text processing, then Python can be a huge benefit and timesaver. It also has a large range of current training materials. Python is an interpreted language, meaning there is not syntax checking step before the script is run. So rather than a quick sanity check for typos, you end up running the program and it stops when it hits an error.

 

There are a couple of Python syntax issues that I personally dislike (hate). First, I am a poor typist, and if you have read many of my posts, you know I have a very strange idea of capitalization.  Python is "case sensitive" meaning that variables name Variable, variable, vAriable, VARIABLE are all different. In Pascal those are all treated as the same thing, which is a huge benefit for me during development. (I try to fix/standardize cases when I am finishing a script.)

 

The second issue I have with Python is that it is "White Space Delimited". This means that to make a block of code all you have to do is indent every line the same amount rather than the extra typing of Begin/End. But to me, this makes it much harder to read the code as there are no markers for where a block begins or ends. Also for a poor typist, having an extra space somewhere in a page of code can completely change how the code executes. And Python treats spaces and tabs differently, so you should really pick one or the other for indenting code an always use that one. Even if two lines look like they are indented identically, if one has a tab and the other 4 spaces, the Python interpreter will not see them as part of the same block.

 

Benefits/limitations inside Vectorworks

 

Vectorscript has functions that will wait for the user to click and then collect that data for use later in the script. Python inside VW is that it does not have a way to pause while waiting for a mouse click and work arounds are required to get data input from the mouse.

 

Vectorscript uses only the single quote mark to delimit strings. And also uses the single quote as the marker for units in feet. This means that you can end up with cases where you have to go to extra lengths to "escape" the single quotes if you need them inside of a string.

 

Python allows you to use both single and double quotes which can minimize this, but then can have the same types of issues with inches and double quotes.

 

Benefits/limitation outside of Vectorworks

 

Python has a huge number of libraries to allow access to web data in almost any format. You can bring in data with just a few library calls. Vectorscript has very limited ability to access outside data. You can read and write text files and XML files, but looking up data on a web site is difficult/impossible.

 

Pythons library for math/matrices/text handling give it a huge edge is you are doing these functions. Vectorscript has basic capabilities in these areas, but there are things Python can do that VS can't.

 

So Which Is Better?

 

It depends on what you are planning to do.

 

Since the Vectorscript functions are just a library inside of Python, you have to learn that no matter which language you use.

 

There are many more examples to learn from in Vectorscript that in Python currently, but the number of Python scripts posts is growing quickly.

 

If you are planning to just write relatively small scripts to create/modify/queary objects in a drawing, I would recommend Vectorscript. While there are fewer learning resources, I think there are enough and beyond a few language specific items most of the questions are going to be about Vectorscirpt specific functions, not how the language works. The Vectorsciript Language Guide https://developer.vectorworks.net/images/7/72/VectorScriptGuide.pdf does a pretty good job our outlining how the language works.

 

If you are looking to do large projects, especially ones that need to access data from outside of VW or if you want to be able to take more of what you learn about programming and apply it in a different environment, then pick Python.

 

In either case, you have picked a great place to learn to program as we have an experienced, friendly, and generous group of coders in both languages. Don't ever hesitate to ask for help. We have all been at the beating our heads on the desk stage many, many times and will be happy to help bring another scripter into the fold.

 

Pat

 

  • Like 1
Link to comment

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.

Guest
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.

×
×
  • Create New...