-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling "path.flattening()" on some DXF files crashes the Python interpreter #663
Comments
This is a know issue if handling with big coordinates. The POLYLINE entity has an elevation of 1.391912e+19. I have no idea how to solve this issue. The best solution is to keep coordinates of entities in the range of planet earth ;-). I will try to avoid the stack overflow in the c-extension. |
A fix could be to translate this entities to the xy-plane: from ezdxf import path
...
for e in doc.modelspace().query('POLYLINE LWPOLYLINE'):
z = e.dxf.elevation.z
if z > 1e12:
e.translate(0, 0, -z)
p = path.make_path(e)
vertices = list(p.flattening(tolerance)) |
This solution is also not perfect, the result differs from the result with small coordinates, but at least no recursion error will be raised. The perfect solution would be: 1. detect curve control point extents 2. move curve near origin and store original offset 3. flatten curve and add offset to result vertices 4. move curve back, if curve processing handled inplace as the current implementation does This is too much additional processing for a slightly better result and large coordinates are the exception like elevation > 1e12 in some 2D DXF files!
Thanks for your reply, the workaround is working indeed 👍 I will also implement some scale-check on loading, I guess it's on the z-plane only, because drawings must be otherwise properly scaled. Thanks again! |
The latest implementation should fix the large coordinate issue for The only unresolved problem are curves where the distances between control points are very large, but this is an inherent floating point problem. |
Making a
path
out of a POLYLINE and callingpath.flattening()
crashes the Python interpreter with 0xC00000FD with some DXF files (which look completely normal files).This is a code snippet you might use:
doc, _ = ezdxf.recover.readfile(filename)
entities = list(doc.modelspace().query('POLYLINE LWPOLYLINE'))
for entity in entities:
path = ezdxf.render.path.make_path(entity)
# This crashes Python interpreter with 0xC00000FD
vertices = list(path.flattening(tolerance))
# render/path.py:671 -> return Bezier4P((s, c1, c2, e)).flattening(distance, segments)
I'm Python 3.8.7 64bit on Windows 10 and ezdxf==0.15.2 (but I also tried 0.17.2, current stable version at the time of writing)
Thanks in advance for your support 👍
Crash.zip
The text was updated successfully, but these errors were encountered: