Python Sample Menu Command: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
(Created page with "{{LocationMain|category=LocationPYSpecial|specific=}} <div class="rightmenu"> __TOC__ </div> == How to install == # Download the sample: File:PythonSample_Menu2.zip # Ins...")
 
No edit summary
 
Line 5: Line 5:
== How to install ==
== How to install ==


# Download the sample: [[File:PythonSample_Menu2.zip]]
* Download the sample: [[File:PythonSample_Menu2.zip]]
# 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.
* 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.
# 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
::<b>Note:</b> it is advisable to create a sub folder inside 'Plug-ins' and copy the sample files inside. This way all your plug-ins will be organized.
* 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 ==
== How the sample works ==
Line 15: Line 16:
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.  
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.  


<code lang="py>
<code lang="py">
import _main
import _main
_main.execute()
_main.execute()

Latest revision as of 19:00, 20 September 2013

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

How to install

  • Download the sample: File:PythonSample Menu2.zip
  • 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.
Note: it is advisable to create a sub folder inside 'Plug-ins' and copy the sample files inside. This way all your plug-ins will be organized.
  • 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