Problem outputting arc to dxf file
-
I have written a script that outputs simple 2D drawings to a dxf file, but I am having some trouble with arcs. Sometimes they output fine, other times they are either facing the wrong way or in the wrong location.
This is the code I'm using to output arcs. The start_angle of ArcCurves was always 0.0 so I created the get_new_angle function to calculate the angle of a line from the center of the arc to the start point, I use that as the start_angle and add it to end_angle.
Any help with this would be appreciated, Thanks
def dxf_output_arc(curve, layername) #curve is an ArcCurve object #layername is the name of the layer the object is on points = curve.center new_angle = get_new_angle(points, curve.vertices[0].position) $dxf_file.puts( " 0\nARC\n8\n"+layername+"\n") $dxf_file.puts(10.to_s+"\n"+(points.x.to_f * $conversion_factor).to_s)#x $dxf_file.puts(20.to_s+"\n"+(points.y.to_f * $conversion_factor).to_s)#y $dxf_file.puts(30.to_s+"\n"+(points.z.to_f * $conversion_factor).to_s)#z $dxf_file.puts(40.to_s+"\n"+(curve.radius.to_f * $conversion_factor).to_s)#radius $dxf_file.puts(50.to_s+"\n"+new_angle.to_f.to_s)#start_angle $dxf_file.puts(51.to_s+"\n"+((curve.end_angle.degrees + new_angle).to_f).to_s)#end_angle end def get_new_angle(center, point) #This function returns the angle of a line return Math;;atan(((center.y.to_f - point.y.to_f)/(center.x.to_f - point.x.to_f))).to_f.degrees.abs end -
I wouldn't rely on start_angle to always be 0.0. I think I remember doing some work with arcs where I found cases where the start_angle where not 0.0.
-
I could change it so it recalculates the end_angle as well, that way I would not have to worry what SketchUp says the angle is. But I think I have bigger issues than that.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement