• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Problem outputting arc to dxf file

Scheduled Pinned Locked Moved Extensions & Applications Discussions
extensions
3 Posts 2 Posters 472 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    timc
    last edited by 17 Sept 2009, 12:11

    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
    
    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 17 Sept 2009, 13:34

      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.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • T Offline
        timc
        last edited by 17 Sept 2009, 17:33

        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.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          3/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement