vlachoudis / bCNC

GRBL CNC command sender, autoleveler and g-code editor
GNU General Public License v2.0
1.54k stars 528 forks source link

Fix edge case in DXF import, closes #1499 #1820

Closed jlirochon closed 1 year ago

jlirochon commented 1 year ago

Introduction

According to DXF Reference, entities have group codes (which are named tags in bCNC). Some of the group codes, on some entities, represent list values. For example the doc for LWPOLYLINE entity on group code 10 says "Vertex coordinates (in OCS), multiple entries; one entry for each vertex".

Problem

Current implementation in bCNC is lazy, it doesn't know if the value should be a list or not :

The problem exhibited in xmas_w_logo.dxf.zip is that the lazy implementation doesn't work when the group contains a single entry : the stored value has no opportunity to be converted to a list. It remains a scalar, a float in this case, then an Exception is raised when bCNC tries to access sub elements as if it was a list.

Proposed fix

Fixes loading of the example file attached in xmas_w_logo.dxf.zip from #1499

Harvie commented 1 year ago

Thank you