dhughes3 Posted May 16, 2019 Share Posted May 16, 2019 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? Quote Link to comment
Pat Stanford Posted May 16, 2019 Share Posted May 16, 2019 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. Quote Link to comment
PatW Posted May 16, 2019 Share Posted May 16, 2019 (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 May 16, 2019 by PatW Quote Link to comment
dhughes3 Posted May 16, 2019 Author Share Posted May 16, 2019 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? Quote Link to comment
Pat Stanford Posted May 16, 2019 Share Posted May 16, 2019 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. 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.