some small additions to code quality
This commit is contained in:
parent
9121ab388d
commit
8d9e0ddf5b
@ -313,7 +313,11 @@ class DXFDWGImport(inkex.Effect):
|
|||||||
self.openExplorer(temp_output_dir)
|
self.openExplorer(temp_output_dir)
|
||||||
|
|
||||||
elif self.options.dxf_to_svg_parser == "ezdxf":
|
elif self.options.dxf_to_svg_parser == "ezdxf":
|
||||||
|
try:
|
||||||
doc = ezdxf.readfile(dxf_file)
|
doc = ezdxf.readfile(dxf_file)
|
||||||
|
#msp = doc.modelspace() #loop through entities
|
||||||
|
#for e in msp:
|
||||||
|
# inkex.errormsg(e)
|
||||||
#doc.header['$DIMSCALE'] = 0.2 does not apply to the plot :-(
|
#doc.header['$DIMSCALE'] = 0.2 does not apply to the plot :-(
|
||||||
#inkex.utils.debug(doc.header['$DIMSCALE'])
|
#inkex.utils.debug(doc.header['$DIMSCALE'])
|
||||||
#inkex.utils.debug(doc.header['$MEASUREMENT'])
|
#inkex.utils.debug(doc.header['$MEASUREMENT'])
|
||||||
@ -330,10 +334,17 @@ class DXFDWGImport(inkex.Effect):
|
|||||||
plt.gca().yaxis.set_major_locator(plt.NullLocator())
|
plt.gca().yaxis.set_major_locator(plt.NullLocator())
|
||||||
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
|
plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
|
||||||
out = MatplotlibBackend(fig.add_axes(ax))
|
out = MatplotlibBackend(fig.add_axes(ax))
|
||||||
Frontend(RenderContext(doc), out).draw_layout(doc.modelspace(), finalize=True)
|
Frontend(RenderContext(doc), out).draw_layout(msp, finalize=True)
|
||||||
#plt.show()
|
#plt.show()
|
||||||
#fig.savefig(os.path.join(temp_output_dir, outputfilebase + ".png"), dpi=300)
|
#fig.savefig(os.path.join(temp_output_dir, outputfilebase + ".png"), dpi=300)
|
||||||
fig.savefig(svg_file) #see https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html
|
fig.savefig(svg_file) #see https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html
|
||||||
|
except IOError:
|
||||||
|
inkex.errormsg("Not a DXF file or a generic I/O error.")
|
||||||
|
exit(1)
|
||||||
|
except ezdxf.DXFStructureError:
|
||||||
|
inkex.errormsg("Invalid or corrupted DXF file.")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
elif self.options.dxf_to_svg_parser == "legacy":
|
elif self.options.dxf_to_svg_parser == "legacy":
|
||||||
inkex.utils.debug("The selected legacy DXF to SVG parser is not supported by this extension yet. Use File > Import > *.dxf. This calls the \"dxf_input.inx\" extension.")
|
inkex.utils.debug("The selected legacy DXF to SVG parser is not supported by this extension yet. Use File > Import > *.dxf. This calls the \"dxf_input.inx\" extension.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
Reference in New Issue
Block a user