Several bugfixes in DXF/DWG Importer
This commit is contained in:
parent
5a06de7bd9
commit
a724a3dc12
@ -26,7 +26,8 @@ import inkex
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import subprocess, tempfile
|
||||
import subprocess
|
||||
import tempfile
|
||||
from lxml import etree
|
||||
from subprocess import Popen, PIPE
|
||||
import shutil
|
||||
@ -357,8 +358,8 @@ class DXFDWGImport(inkex.Effect):
|
||||
if emptyGroup is not None:
|
||||
emptyGroup.getparent().remove(emptyGroup)
|
||||
|
||||
#empty the following vals because they destroy the size aspects of the import
|
||||
if self.options.dxf_to_svg_parser == "bjnortier":
|
||||
#empty the following vals because they destroy the size aspects of the import / make viewbox looking wrong
|
||||
if self.options.dxf_to_svg_parser == "bjnortier" or self.options.dxf_to_svg_parser == "kabeja":
|
||||
doc.set('width','')
|
||||
doc.set('height','')
|
||||
doc.set('viewBox','')
|
||||
@ -371,18 +372,21 @@ class DXFDWGImport(inkex.Effect):
|
||||
#if child.tag == inkex.addNS('g','svg'):
|
||||
elements.append(child)
|
||||
|
||||
#build some of bounding boxes and ignore errors for faulty elements (sum function often fails for that usecase!)
|
||||
#build sum of bounding boxes and ignore errors for faulty elements (sum function often fails for that usecase!)
|
||||
bbox = None
|
||||
try:
|
||||
bbox = elements[0].bounding_box() #init with the first bounding box of the tree (and hope that it is not a faulty one)
|
||||
except:
|
||||
except Exception as e:
|
||||
#inkex.utils.debug(str(e))
|
||||
pass
|
||||
count = 0
|
||||
for element in elements:
|
||||
if count == 0: continue #skip the first
|
||||
if count != 0: #skip the first
|
||||
try:
|
||||
bbox.add(element.bounding_box())
|
||||
except:
|
||||
#bbox.add(element.bounding_box())
|
||||
bbox += element.bounding_box()
|
||||
except Exception as e:
|
||||
#inkex.utils.debug(str(e))
|
||||
pass
|
||||
count += 1 #some stupid counter
|
||||
if bbox is not None:
|
||||
|
Reference in New Issue
Block a user