Jump to content

how to use vs.py in visual studio code


Recommended Posts

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)?

Link to comment

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.

 

Link to comment

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 by twk
  • Like 1
Link to comment
  • 1 month later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...