I am using ezdxf to read some .dxf files. The goal is to read the file using ezdxf and access each entity the the drawing's modelspace to find arc lengths.
import ezdxf
file_path = "IRREGULAR.dxf"
doc = ezdxf.readfile(file_path)
msp = doc.modelspace()
for entity in msp:
print(entity.dxftype())
# I have some more code for other line types
if entity.dxftype() == 'ARC':
center_point = entity.dxf.center
radius = entity.dxf.radius
start_angle = entity.dxf.start_angle
end_angle = entity.dxf.end_angle
print(arc_length(radius, start_angle, end_angle))
I have created a function called arc_length that calculates arc lengths based on each arc's dimensions.
This is the irregular shape I am currently working with.
This shape is broken down into multiple arcs.
I am viewing the same drawing on a CAD software to see how the arc lengths between my code and the CAD software compare. The challenge is that out of the 6 arcs in this drawing, I am getting 5 dimensions that are exactly matching in both places. However, the rightmost arc length is way too off in my code. I verified and there are no additional layes or blocks that are unseen, and that I am looking at the same drawing in both places.
If I can get any help on how to fix this, or leads on what the potential issue could be, it would be extremely helpful. Thanks!
Something I tried was getting all arc dimensions and then recreating a shape using those. Surpringly, the shape after this reverse engineering turned out to be the correct shape that I started with. This is strange because if the arc dimensions were wrong, then I would have ended up with a weird shape.
end_angle - start_anglewill not give the included angle, but rather360 minus included angle. if it uses that value to compute an arc length, you will not get the correct result. I expect your "reverse engineered" shape was still correct because if arcs are created from Start, end, center parameters this does not depend on length or included angle.