Jump to content
Sign in to follow this  
Patrick Winkler

Batch Converting - Open, Change and Close Files with python

Recommended Posts

Hello,

I'm working on a script which changes the units off all VWX files in a folder.

The Problem is that the file opens to late when the script is already finished. I also tried it with the sleep () command.

Is there a way to open a file and make it active within a function?


def main ():    

   # Get File
   succes, path = vs.GetFileN('', None, None)

   # Open File

   if get_OS_Code() == OS_WIN:
       # Windows command
       os.system('start' + path )
   else:
       # Mac command
       os.system('open  ' + path ) 

   # Set Units 
   Millimeters =     7
   Centimeters =   8
   Meters = 9
   Kilometers = 10

   vs.Units (Centimeters)

   # Save the File
   vs.DoMenuTextByName("Save", 0)

   # Close the File
   vs.DoMenuTextByName("Close", 0)

Share this post


Link to post

If you're on the Mac, use AppleScript to handle opening and saving. VW provides an apple script command to run a python script.

-Josh

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
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.

×