When I try to use the flattening method of a 3D arc dxf entity I get vertexes that actually do not lie on the arc.
Here is an example modified from the arc.py example.
import ezdxf
from ezdxf.math import Vec3, ConstructionArc, UCS
# create a 3D arc from 3 points in WCS
start_point_wcs = Vec3(3, 0, 0)
end_point_wcs = Vec3(0, 3, 0)
def_point_wcs = Vec3(0, 0, 3)
# create UCS
ucs = UCS.from_x_axis_and_point_in_xy(
origin=def_point_wcs,
axis=start_point_wcs - def_point_wcs,
point=end_point_wcs,
)
start_point_ucs = ucs.from_wcs(start_point_wcs)
end_point_ucs = ucs.from_wcs(end_point_wcs)
def_point_ucs = Vec3(0, 0) # origin of UCS
# create arc in the xy-plane of the UCS
arc = ConstructionArc.from_3p(start_point_ucs, end_point_ucs, def_point_ucs)
arc.add_to_layout(modelspace, ucs, dxfattribs={"color": 1}) # red arc
arc2=modelspace.query("ARC")[0]
points=list(arc2.flattening(1))
print(f"start: {arc2.start_point} end: {arc2.end_point}")
print(points)
for p in points:
modelspace.add_point(p)
# saving DXF file
filename = "arcs.dxf"
doc.saveas(filename)
print("drawing '%s' created.\n" % filename)`
start: (3.000000000000001, 5.551115123125783e-16, -4.440892098500626e-16) end: (6.661338147750939e-16, 3.0, 2.220446049250313e-16)
[Vec3(2.0, -0.999999999999999, -1.000000000000001), Vec3(1.0000000000000007, 0.9999999999999993, -2.0), Vec3(-0.9999999999999986, 1.9999999999999996, -1.000000000000001)]
Discussed in #654
Originally posted by ValerioMussi March 16, 2022
Hi @mozman!
There is something I cannot properly understand about using the flattening method of the arc dxf entity. Can you please help me figuring out what I'm doing wrong?
When I try to use the flattening method of a 3D arc dxf entity I get vertexes that actually do not lie on the arc.
Here is an example modified from the arc.py example.
The output I get is:
And here is a screenshot from Draftsight:

Thanks,
Valerio.