mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
937 stars 191 forks source link

add_spline methods not rendering correctly when using decimal points #1022

Closed subsurfaceiodev closed 10 months ago

subsurfaceiodev commented 10 months ago

Describe the bug When using floats / decimal fit_points in add_spline, add_open_spline, etc. methods splines are not rendered correctly in AutoCAD. REGENALL after opening exported dxf command fixes this problem but it is not ideal.

To Reproduce Information and data needed to reproduce the error: Based on https://ezdxf.readthedocs.io/en/stable/tutorials/spline.html#splines-from-fit-points:

doc = ezdxf.new("R2000")

fit_points = [(0, 0, 0), (0.750, 0.500, 0), (1.750, 0.500, 0), (2.250, 1.250, 0)]
msp = doc.modelspace()
spline = msp.add_spline(fit_points)

Expected behavior Splines to be rendered correctly by default

Screenshots Before REGENALL: image After REGENALL: image

mozman commented 10 months ago

This is not a bug this is a feature of CAD applications.

In the default view the SPLINE is very small, so the CAD application does not waste time to render a high-resolution curve:

image

The drawing add-on of ezdxf ignores the drawing extents and renders always a smooth spline by default:

image

In this case you can zoom closer to the SPLINE by:

from ezdxf import zoom

# snip -x-x-x-x-x

zoom.extents(msp)
doc.saveas("your.dxf")

This narrows the modelspace extents to the curve and the default view looks like this:

image

However, in general, you always need to use the REGEN command to get smoother curves.

subsurfaceiodev commented 10 months ago

Excellent as always, thanks @mozman