Python Sample Menu Command

From Vectorworks Developer
Revision as of 18:54, 20 September 2013 by Root (talk | contribs) (Created page with "{{LocationMain|category=LocationPYSpecial|specific=}} <div class="rightmenu"> __TOC__ </div> == How to install == # Download the sample: File:PythonSample_Menu2.zip # Ins...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

.Python|Python ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix ..Python Debugging|Debugging with Python

How to install

  1. Download the sample: File:PythonSample Menu2.zip
  2. Install the sample by coping the contents of the zip file into your users 'Plug-ins' folder. The easiest way to find this folder is by going to Vectorworks menu Tools -> Options -> Vectorworks Preferences... then in the 'User Folder' tab click on 'Explore...' button and navigate to the 'Plug-ins' sub-folder.
  3. Run Vectorworks and edit the Workspace (from the menu Tools -> Workspaces -> Workspace Editor) to add the new menu command. It can be found under the 'Sample Python' category

How the sample works

The sample adds a new menu command defined by the 'vsm' file which represents a plug-in. You can see this plug-in under the menu Tools -> Plug-ins -> Plug-in Manager. There you can edit properties of the script as well as the script text itself.

The script for this sample 'import's python module (represented by a separate file) called '_main.py'. This module defines the behavior of the plug-in.

import _main
_main.execute()

When the sample menu command is executed it script imports the '_main' module and runs the 'execute' function inside. It demonstrates how to show a dialog, collect some data, and act on the data.

See Also

Python basic information: Python

Script Function Reference