updated dxfgrabber library: 0.8.1 -> 0.8.4

This commit is contained in:
Lukas Treyer 2017-06-01 14:06:06 +02:00
parent 6129bc3102
commit d2ed52f213
Notes: blender-bot 2023-02-14 19:38:45 +01:00
Referenced by issue #51690, DXF importer: some 3dFaces are not imported without warning or errors
4 changed files with 28 additions and 13 deletions

View File

@ -3,7 +3,7 @@
# Created: 21.07.2012
# License: MIT License
version = (0, 8, 1)
version = (0, 8, 4)
VERSION = "%d.%d.%d" % version
__author__ = "mozman <mozman@gmx.at>"

View File

@ -190,8 +190,8 @@ class Text(DXFEntity):
self.halign = 0
self.valign = 0
self.align_point = None
self.font = ""
self.big_font = ""
self.font = None
self.big_font = None
def setup_attributes(self, tags):
for code, value in super(Text, self).setup_attributes(tags):

View File

@ -33,14 +33,12 @@ class Sections(object):
def name(section):
return section[1].value
bootstrap = True
for section in iterchunks(tagreader, stoptag='EOF', endofchunk='ENDSEC'):
if bootstrap:
if name(section) == 'HEADER':
new_section = HeaderSection.from_tags(section)
drawing.dxfversion = new_section.get('$ACADVER', 'AC1009')
codepage = new_section.get('$DWGCODEPAGE', 'ANSI_1252')
drawing.encoding = toencoding(codepage)
bootstrap = False
else:
section_name = name(section)
if section_name in SECTIONMAP:

View File

@ -38,6 +38,23 @@ def is_point_tag(tag):
return tag[0] in POINT_CODES
infinite = float('inf')
neg_infinite = float('-inf')
def to_float_with_infinite(value):
try:
return float(value)
except ValueError:
value = value.lower().strip()
if value.startswith('inf'):
return infinite
if value.startswith('-inf'):
return neg_infinite
else:
raise
class TagCaster:
def __init__(self):
self._cast = self._build()
@ -74,14 +91,14 @@ class TagCaster:
TYPES = [
(tostr, range(0, 10)),
(point_tuple, range(10, 20)),
(float, range(20, 60)),
(to_float_with_infinite, range(20, 60)),
(int, range(60, 100)),
(tostr, range(100, 106)),
(point_tuple, range(110, 113)),
(float, range(113, 150)),
(to_float_with_infinite, range(113, 150)),
(int, range(170, 180)),
(point_tuple, [210]),
(float, range(211, 240)),
(to_float_with_infinite, range(211, 240)),
(int, range(270, 290)),
(int, range(290, 300)), # bool 1=True 0=False
(tostr, range(300, 370)),
@ -92,12 +109,12 @@ TYPES = [
(int, range(420, 430)),
(tostr, range(430, 440)),
(int, range(440, 460)),
(float, range(460, 470)),
(to_float_with_infinite, range(460, 470)),
(tostr, range(470, 480)),
(tostr, range(480, 482)),
(tostr, range(999, 1010)),
(point_tuple, range(1010, 1020)),
(float, range(1020, 1060)),
(to_float_with_infinite, range(1020, 1060)),
(int, range(1060, 1072)),
]
@ -121,8 +138,8 @@ def stream_tagger(stream, assure_3d_coords=False):
value = stream.readline()
line.counter += 2
if code and value: # StringIO(): empty strings indicates EOF
return DXFTag(int(code[:-1]), value[:-1]) # without '\n'
else: # StringIO(): missing '\n' indicates EOF
return DXFTag(int(code.rstrip('\r\n')), value.rstrip('\r\n')) # without line ending
else: # StringIO(): empty lines indicates EOF
raise EOFError()
while True: