Skip to content
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

3D Arc flattening error #655

Closed
mozman opened this issue Mar 16, 2022 Discussed in #654 · 1 comment
Closed

3D Arc flattening error #655

mozman opened this issue Mar 16, 2022 Discussed in #654 · 1 comment

Comments

@mozman
Copy link
Owner

mozman commented Mar 16, 2022

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.

mozman added a commit that referenced this issue Mar 16, 2022
The OCS elevation of the ARC stored in center.z was ignored.
@mozman
Copy link
Owner Author

mozman commented Mar 16, 2022

This should be fixed now.

@mozman mozman closed this as completed Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant