Benedick_Miller Posted October 29, 2018 Share Posted October 29, 2018 Hi, I am just starting off with python for Vectorworks - I use Visual Studio Code (VS Code) as my IDE on a Mac (MacOS 10.13) I have downloaded vs.py but I have no idea how to set up VS Code to "see" vs.py for intelli-sense or linting The instructions: "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)" don't help me much. Can anyone explain the steps needed to point VS Code to vs.py (or an alternative)? Quote Link to comment
PatW Posted October 30, 2018 Share Posted October 30, 2018 Hi, I can't tell you exactly how it is done in vs code. But normaly you add the folder which contain the vs.py to the search paths. Then just for intellisense you have to make an import at the files where you want to use vs functions: import vs Or alternatively you can just put the vs.py next to your script.py but the first way is definetely better. Quote Link to comment
Benedick_Miller Posted October 30, 2018 Author Share Posted October 30, 2018 Thanks for the reply. The trouble is I don't know how, or where, to edit the VS Studio search paths. I'll keep trying! Quote Link to comment
twk Posted October 31, 2018 Share Posted October 31, 2018 (edited) Never had to edit VS Studio search paths. When I did used VS Studio, the vs file was just kept in the root folder. (I use PyCharm Community Edition now, far superior) The vs.py file must be in your projects root folder. our folder structure: L:\Documents\VisualStudio Projects\Custom Vectorworks\Plugins\Custom Scripts\ - "L:\Development\VisualStudio Projects" is our Projects folder in Visual Studio - "L:\Development\VisualStudio Projects\Custom Vectorworks" is our one of the paths in our Vectorworks Preferences "Workgroup and Project Folders" paths - "Custom Scripts" is the root folder where all our scripts are Under the custom scripts folder we have other folders organised by vectorworks specific functions: \obj_wrappers \document_properties_wrappers \etc.. When it comes time to coding, below is sort of the start off:(FYI example shows custom modules we've made to make coding in VW easier). Search for DLibrary in the forums for Dieter's amazing VW python library. import vs from obj_wrappers import vw_Obj from document_properties import * OBJ = vwObj(vs.FSActLayer()) # vw_Obj is a custom made class wrapper that contains every property a vectorworks object may have eg. width, height, layer, class, type, etc.." height = OBJ.height width = OBJ.width obj_layer = OBJ.on_layer alert_dialog(obj_layer) In my experience, VS Studio picks up intelli-sense for vs.py and my custom modules. Showing documentation, and auto-completion etc Edited October 31, 2018 by twk 1 Quote Link to comment
Benedick_Miller Posted October 31, 2018 Author Share Posted October 31, 2018 hi twk, thank you very much for this, very helpful. I will try this later. It makes sense. Sorry for "dumb" questions - I am trying to teach myself Python at the same time as learning how to use VS code, so I can update my ancient Vectorscript plugins. All the help in this forum is much appreciated. Quote Link to comment
Benedick_Miller Posted December 30, 2018 Author Share Posted December 30, 2018 @twk thanks again for your help. I have switched to PyCharm Community Edition now, thanks for the tip 😀 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.