VS:Implementing Installation Script

From Vectorworks Developer
Revision as of 03:37, 12 May 2015 by Orso.b.schmid (Talk | contribs)

Jump to: navigation, search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

What's that

If we follow the basic installation, each time we install a plug-in we need to edit our workspace to be able to use the plug-in functionality: Either we have to edit the menu bar or our tool set.

Fortunately Vectorworks has the ability to save any edited workspace and it can be loaded if it is put either in the Vectorworks or user workspace folder. So the best way to remove the burden of editing workspace each time a plug-in is installed, is that we can save our workspace once and put it in user workspace folder. However basic installation is unable to do that since it only copy the files to user plug-in folder. And that's where writing an installation script becomes useful:

Each time a new plug-in is installed, Vectorworks looks for a installation script (install.py) and runs it befor concluding the installation. Following is an example of such installation script written in python:

import shutil
import os
import vs

# Set a name for a better folder organization
plugin_name = "Sample1"

# Use negative number to get user path and positive number to get application path 
VW_USER_LIBARY_PATH = vs.GetFolderPath(-13)
VW_USER_WORKSPACE_PATH = vs.GetFolderPath(-4)
VW_USER_PLUGINs_PATH = vs.GetFolderPath(-2)

if not os.path.exists(os.path.join(VW_USER_LIBARY_PATH , plugin_name )):
    os.makedirs(os.path.join(VW_USER_LIBARY_PATH , plugin_name )) 

if not os.path.exists(os.path.join( VW_USER_WORKSPACE_PATH )):
    os.makedirs(os.path.join( VW_USER_WORKSPACE_PATH )) 

for file in os.listdir(VW_USER_PLUGINs_PATH):
    if file.endswith(".vww"):               													
	       shutil.move(os.path.join(VW_USER_PLUGINs_PATH , file ), os.path.join(VW_USER_WORKSPACE_PATH , file ))
    elif file.endswith(".vwx"):  
	       shutil.move(os.path.join(VW_USER_PLUGINs_PATH , file ), os.path.join(VW_USER_LIBARY_PATH , plugin_name, file ))

This script simply looks for all workspace and drawing files (.vws and .vwx) and if they existed it moves them to their appropreate folder.

Now having this script all we have to do is just simply put this scrip in the root folder of our zip file package and install it from Vectorworks:

Sample Install Script.jpg


See also

VS:Basic Installation VS:A more Complicated Installation Script

User Comments

Personal tools

Advanced Search
See Also