Skip to content

MIN_HATCH_LINE_DISTANCE too large for certain DXF files #929

Description

@quipo

Describe the bug
We encountered some DXF files that have a minimum hatching line distance that is smaller than the minimum allowed in the library.
Unfortunately I can't share the DXF file, but I tried reading the file locally and it works fine with this patch against ezdxf 1.1.0:

--- render/hatching.py	2023-09-13 18:50:40.193582134 +0000
+++ render/hatching.py.2	2023-09-13 18:59:45.171383176 +0000
@@ -30,7 +30,7 @@
 if TYPE_CHECKING:
     from ezdxf.entities.polygon import DXFPolygon

-MIN_HATCH_LINE_DISTANCE = 1e-4  # ??? what's a good choice
+MIN_HATCH_LINE_DISTANCE = 1e-8  # ??? what's a good choice
 NONE_VEC2 = Vec2(math.nan, math.nan)
 KEY_NDIGITS = 4
 SORT_NDIGITS = 10

(alternatively, can it be configured via the API?)

We also had this other patch lying around, which used to fix another issue we had, in case it makes sense to apply it:

--- proxygraphic.py	2023-09-13 18:39:33.238367076 +0000
+++ proxygraphic.py.2	2023-09-13 18:47:23.549997247 +0000
@@ -562,6 +562,10 @@
         if flag & 512:  # todo: is this correct? not documented by the ODA DWG ref.
             is_closed = True
         num_points = bs.read_bit_long()
+
+        if num_points <= 0:
+            return;
+
         if flag & 16:
             num_bulges = bs.read_bit_long()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions