sully8391 Posted September 26, 2020 Share Posted September 26, 2020 Hi All, I'm trying to implement a simple installation script that will copy a resource file into the user libraries folder. I tested it outside of Vectorworks and it successfully copied and pasted the file into the proper folder, but when I try to pair it with installation nothing happens. It actually appears that script isn't running at all. I altered it so it would throw an error, and nothing happened, then I tried to use it to create some text, and still nothing. It's sitting at the same directory level as the folder holding all of the plugins, which appears to be correct according to this page: https://developer.vectorworks.net/index.php/VS:Implementing_Installation_Script Anyone know what I might be missing? Quote Link to comment
JBenghiat Posted September 26, 2020 Share Posted September 26, 2020 The script must be named install.py The script must be at the root level of the zip folder. If it is inside an enclosing folder, it will not run. This could present an issue if a user unzips the install package and then tries to re-zip. In 2018 SP1 and up, you can work around this by changing the zip extension to .vwlibrary Quote Link to comment
sully8391 Posted September 26, 2020 Author Share Posted September 26, 2020 I see, I totally just compressed it wrong. It's running now, but I'm having loads of trouble getting to the directory that the actual file is in. I've tried os.getcwd() and os.path.dirname(sys.argv[0]), but both of those return the directory of the process (different from when I run the script standalone). I need a way to locate the resource file no matter where a user saves the downloaded zip. I might have more luck programming at a more reasonable hour, but if you know a magic line of code that achieves this, I'd love to hear it. Quote Link to comment
tbexon Posted September 26, 2020 Share Posted September 26, 2020 So from my understanding the when you install the ZIP file it copies all the contents of the Zip FIle into the Users Plug in folder, so could you not package the Rource file within the .Zip then use vs.GetFolderPath() to get the users plug in folder, aswell as Library Folder and use shutil.move to move them from plugins folder to required folder. import shutil import os import vs def manualPackageInstall(foldername): shutil.move(os.path.join(vs.GetFolderPath(-2) , foldername ), # Path to Folder to move in plugin Folder os.path.join(vs.GetFolderPath(-13) , foldername)) # Path to Libraries in User Folder Something like that? Quote Link to comment
JBenghiat Posted September 26, 2020 Share Posted September 26, 2020 10 hours ago, sully8391 said: I see, I totally just compressed it wrong. It's running now, but I'm having loads of trouble getting to the directory that the actual file is in. I've tried os.getcwd() and os.path.dirname(sys.argv[0]), but both of those return the directory of the process (different from when I run the script standalone). I need a way to locate the resource file no matter where a user saves the downloaded zip. I might have more luck programming at a more reasonable hour, but if you know a magic line of code that achieves this, I'd love to hear it. outputFolder is the magic variable that holds the path to the installed location. This is usually the user plug-ins folder, though using this variable would catch installing into a workgroup folder. Quote Link to comment
sully8391 Posted September 26, 2020 Author Share Posted September 26, 2020 @tbexon Yes, I tried locating the file in the plugins folder and moving it from there, and everything works. That link I posted actually mentions this, but I wasn't reading closely enough. Thank you! Quote Link to comment
Recommended Posts
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.