Small fix in DXF/DWG Importer

This commit is contained in:
Mario Voigt 2020-09-08 01:12:27 +02:00
parent 2ec01ffc77
commit 9bcfcc3f47
2 changed files with 10 additions and 4 deletions

View File

@ -23,6 +23,7 @@
<option value="px">px</option>
</param>
<param name="inputfile" type="path" gui-text="Import File (*.dxf, .dwg)" gui-description="Full path to your file, e.g. 'C:\Users\Username\Documents\myimage.jpg'" filetypes="dxf,dwg" mode="file">C:\Users\</param>
<param name="opendironerror" type="bool" gui-text="Open containing output directory on conversion errors">true</param>
<spacer/>
<label appearance="header">About</label>
<separator/>
@ -148,7 +149,6 @@
<label appearance="header">sk1 UniConvertor 1.1.X</label>
<separator/>
<param name="sk1_uniconverter" type="path" gui-text="uniconvertor executable" gui-description="Full path to 'uniconvertor' executable" filetypes="cmd" mode="file">C:\Program Files (x86)\sK1 Project\UniConvertor-1.1.6\uniconvertor.cmd</param>
<param name="opendironerror" type="bool" gui-text="Open containing output directory on conversion errors">true</param>
</page>
</param>
<effect needs-live-preview="true">

View File

@ -110,7 +110,11 @@ class DXFDWGImport(inkex.Effect):
self.arg_parser.add_argument("--UNDERLAY", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--XLINE", type=inkex.Boolean, default=True)
def openExplorer(self, temp_output_dir):
if os.name == 'nt':
subprocess.Popen(["explorer",temp_output_dir],close_fds=True)
else:
subprocess.Popen(["xdg-open",temp_output_dir],close_fds=True)
def effect(self):
#get input file and copy it to some new temporary directory
@ -270,7 +274,7 @@ class DXFDWGImport(inkex.Effect):
if proc.returncode != 0:
inkex.errormsg("UniConverter failed: %d %s %s" % (proc.returncode, stdout, stderr))
if self.options.opendironerror:
subprocess.Popen(["explorer",temp_output_dir],close_fds=True)
self.openExplorer(temp_output_dir)
elif self.options.dxf_to_svg_parser == "bjnortier":
if which("node") is None:
@ -284,7 +288,7 @@ class DXFDWGImport(inkex.Effect):
if proc.returncode != 0:
inkex.errormsg("node.js DXF to SVG conversion failed: %d %s %s" % (proc.returncode, stdout, stderr))
if self.options.opendironerror:
subprocess.Popen(["explorer",temp_output_dir],close_fds=True)
self.openExplorer(temp_output_dir)
elif self.options.dxf_to_svg_parser == "kabeja":
wd = os.path.join(os.getcwd(), "kabeja")
@ -293,6 +297,8 @@ class DXFDWGImport(inkex.Effect):
stdout, stderr = proc.communicate()
if proc.returncode != 0:
inkex.errormsg("kabeja failed: %d %s %s" % (proc.returncode, stdout, stderr))
if self.options.opendironerror:
self.openExplorer(temp_output_dir)
elif self.options.dxf_to_svg_parser == "ezdxf":
doc = ezdxf.readfile(dxf_file)