Jump to content
Benedick_Miller

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

Share this post


Link to post

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.

 

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×