jgcseh Posted May 4, 2016 Share Posted May 4, 2016 Hi, 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, Jozsef Quote Link to comment
Patrick Winkler Posted May 4, 2016 Share Posted May 4, 2016 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) 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.