Jump to content
dhughes3

Create New Document

Recommended Posts

Hi. I'm trying to create a script that imports a dwg file and reformats it - I've got the script working but wondered if there is any way to create a new document based on a template at the beginning of the script as that is the only manual step left?

Share this post


Link to post

If you are on a Mac you should be able to use an Applescript to open a new file from the template and then run the script to do the dwg import.

 

Vectorscript/Pythonscript are very document centric, so there is really no way to have them open a different VWX file.

 

It seems like you should be able to script importing of layers and classes like you can from the Organization Palette, but I can't find the right calls in the Function Reference. @JBenghiat Do you have a way to script importing layers and classes?

 

Do you have a single template file or different templates for different uses? If you have only one, then if you name it default.sta (and store it in the right place), it will automatically open when you open VW.

 

Or what about storing the import script as part of a template file. Then to get the script they have to open a new document from the Import Template and then run the script.

 

Ask again if you need more information.

 

Share this post


Link to post
Posted (edited)

The windows equivalent to AppleScript would be ActiveX here:

Unfortunately it's not documented and very unstable. If you are lucky it will work.

 

 

Edited by PatW

Share this post


Link to post

Thanks for the tips, it's a shame about the lack of file manipulation functions - but not the end of the world. Putting the script in the template and running it from there is the approach I have gone with, just thought it would have been nice for the script to handle the file creation and saved a couple of clicks (lazy I know!)

 

One other question though - the script selects objects on an imported layer and copy & pastes them to a different layer. I want to paste it in the middle of the "page" as the template contains viewports targeted at this layer. When it was manual I'd just click in the middle and then paste. The closest I've got so far with scripting is

DoMenuTextByName('Fit To Window',0);
DoMenuTextByName('Paste',0);

and it works mostly but every now and then it pastes off centre. Is there a better way to do it?

 

 

Share this post


Link to post

The script equivalent to clicking in the middle would be MoveTo(0,0);

 

Another option would be to  Group the objects, get a handle to the group, get the center of the group, HMove the group by the negative of the center (i.e. back to 0,0), Change the layer, and ungroup.

 

The ones that are not centered probably have some object way out in space that you need to investigate and either move in closer or delete.

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.

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.


 

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