Sloader Posted May 19, 2021 Share Posted May 19, 2021 I am trying create a script that automates the importing of a variety of files created by a QGIS script (DXF, SHP and some images). As I am new to scripting in VW (and not very good in general) I am trying to get started by importing a single DXF file. I have tried using vs.ImportSingleDXFDWG(pathtomyfile) but that just launches the import dialogue. The APi reference doesn't provide many clues as to the arguments etc for the function or how it works so I don't really know where to start without going to square one and start learning python properly. I am using a mac so I think there might be issues the the path format Quote Link to comment
MullinRJ Posted May 19, 2021 Share Posted May 19, 2021 @Sloader , From the function's description in the Script Reference there are no arguments, so you are not missing anything there. This function emulates the menu command Import Single DXF/DWG... There does not seem to be a command that will open DXF files without system dialogs opening. Raymond 1 Quote Link to comment
Sloader Posted May 20, 2021 Author Share Posted May 20, 2021 Thanks for clarifying, maybe I need to look at the SDK. Not sure I really see the point in the function if all it does is launch the dialogue, that makes the process slower than dragging a dxf onto the page. Quote Link to comment
Tobias Döngi Posted May 29, 2021 Share Posted May 29, 2021 The call you're looking for is vs.ImportDXFDWGFile so your script could look like this: isBatch = True result = vs.ImportDXFDWGFile('C:\\155_01_237_1.dxf', isBatch) vs.AlrtDialog('Result: {}'.format(result)) Setting isBatch to 'True' avoids annoying config dialogs. For macOS you should experiment with the path specifier I'm sure you have to use slashes but haven't tried it. Warning: The online developer reference for this function is outdated, you should use the reference within the script editor accessed by the small clipboard with arrow button. 1 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.