.Python|Python ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix ..Python Debugging|Debugging with Python
What is Python
Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.
Also, here is the article about Python in wikipedia: http://en.wikipedia.org/wiki/Python_(programming_language)
More about Python can be found on the http://www.python.org/ website.
Python has two public versions Python 2.7 and Python 3.x.
Vectorworks uses Python 3 language. This is very important when learning about the language and when writing code.
How to start with Python
First of all you must learn the Python 3 language. The best place to start is the Python documentation page(http://www.python.org/doc/).
The fastest way to learn the language is to read through Python Tutorial pages: http://docs.python.org/3/tutorial/
Python 3 and Vectorworks
Scripting in Vectorworks with Python is very similar to the way VectorScript works in the software. All the existing APIs are available i n the Python scripts inside the 'vs' namespace.
For example a simple script in Python that show an alert dialog looks like that:
- Right-click on the resource browser and create a new script
- Choose language for the script to be 'Python'
- Type the script
When executed with double click on the script in the resource browser, the alert dialog will be displayed.
Full functional reference to the Python Vectorworks API can be found on this page VS:Function_Reference.
These are some introductory samples that demonstrate plug-ins for Vectorworks written in Python. They are with increasing difficulty and demonstrate different aspects in the plug-in development under Vectorworks:
- Sample menu command: Python Sample Menu Command
- Sample point object: Python Sample Point Object
- Sample more complex point object: Python Sample Point Object (complex)
- Sample 2D path object: Python Sample 2D Path Object
- An object that display an image from the web: Python Sample WebLinkImage
IDE and Debugging Python Scripts
Often users would use external IDE to edit the Python scripts that Vectorworks executes. Modern IDEs provide intelli-sense information (information about the semantics of the code while typing). To help intelli-sense for Vectorworks Python script APIs, you can point your IDE to the file File:Vs.zip (download, unzip, and place it appropriately so the IDE could find it). This way the IDE will know all Vectorworks Python functions and it would provide some information on the parameters and the behavior of the function. Note that those functions are empty and will not do anything if executed.
It is possible to debug Python scripts in Vectorworks using a third-party application.
See Python Debugging for more information.
- As described on the Python official website: http://www.python.org