Skip to content

Commit

Permalink
make TEXT entities optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Nov 28, 2018
1 parent a2b47b8 commit 9c27e7d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions trimesh/path/io/dxf.py
Expand Up @@ -296,13 +296,21 @@ def convert_text(e):
"""
Convert a DXF TEXT entity into a native text entity.
"""
# rotation angle converted to radians
angle = np.radians(float(e['50']))
if '50' in e:
# rotation angle converted to radians
angle = np.radians(float(e['50']))
else:
# otherwise no rotation
angle = 0.0

# text with leading and trailing whitespace removed
text = e['1'].strip()

# height of text
height = float(e['40'])
if '40' in e:
height = float(e['40'])
else:
height = None

# origin point
origin = np.array([e['10'],
Expand Down Expand Up @@ -483,8 +491,11 @@ def convert_text(e):
# be able to access them by key as whitespace
# is random and crazy, like: ' 1 '
chunk_raw[:, 0] = entity_blob[index][:, 0]
convert_text(dict(chunk_raw))

try:
convert_text(dict(chunk_raw))
except BaseException:
log.warning('failed to load text entity!',
exc_info=True)
# if the entity contains all relevant data we can
# cleanly load it from inside a single function
elif entity_type in loaders:
Expand Down
2 changes: 1 addition & 1 deletion trimesh/version.py
@@ -1 +1 @@
__version__ = '2.35.38'
__version__ = '2.35.39'

0 comments on commit 9c27e7d

Please sign in to comment.