Skip to content

3D Arc flattening error #655

@mozman

Description

@mozman

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.

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)`

The output I get is:

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)]

And here is a screenshot from Draftsight:
immagine

Thanks,
Valerio.

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