Jump to content
Sign in to follow this  

Problem reading data from file

Recommended Posts


I'm having trouble reading data from a file that will be used for parametric processing and I can't seem to get the vs.Read() function to work. Here is a portion of my script.

import vs
import os

isFileSelected, fileName = vs.GetFileN("Select the part list file:", "~/Documents", "txt")
if isFileSelected:
vs.Open( fileName )
partName = vs.Read()
width = vs.Read()
length = vs.Read()

The file seems to open as expected, but I then I get the following:

File "", line 7, in

AttributeError: 'module' object has no attribute 'Read'

The file I'm reading is tab delimited and currently contains just the part names and their associated width and length.

I have a feeling I missing something simple like formatting or an include.

Also, I have quite a bit programming experience with VectorScript but would like to transition to Python. Is there a good source for example Vectorworks Python scripts beyond the few that are on the developers page?

Thanks in advance,


Share this post

Link to post

Hello jgseh,

I have no idea why your code is not working.

You can use the python file-functions instead which I would prefer anyway:

filen_name = 'test.txt'

f = open (filen_name, mode='r')    

lines = f.readlines ()

print (lines)

for l in lines:
   print (l)

Share this post

Link to post

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.

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.

Sign in to follow this  


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.

  • Create New...