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 first time a tag is encountered, bCNC stores the value as a scalar
the second time this tag is encountered, bCNC replaces the existing scalar with a list of [existing, new] values
then if the tag is encountered again, bCNC appends new values to the stored list
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
Add a static list of tags for which we know we should receive a list.
Correctly initialise a list as soon as the first entry is read.
Remove code converting from scalar to list
Fixes loading of the example file attached in xmas_w_logo.dxf.zip from #1499
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