sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Output arcs to dxf format

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    9 Posts 3 Posters 407 Views 3 Watching
    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 timc

      I am writing a script that allows me to output simple 2D drawings to dxf format, but I am having some trouble with arcs. I can output lines and circles fine but my arcs do not have the correct starting and ending angles, the arc always opens down despite it's orientation in the model.

      How can I correctly output arcs in dxf format?

      [Edit:]I should specify I want to output the arcs as arcs, not a series of lines.

      1 Reply Last reply Reply Quote 0
      • honoluludesktopH Offline
        honoluludesktop
        last edited by

        Hi Tmic, Here is a link to ruby that works for me. I export polylines only, and have not tested the other export extities. If you get yours to work with layers preserved, please post your solution.

        1 Reply Last reply Reply Quote 0
        • T Offline
          timc
          last edited by

          To get the proper layer name for each entity you have to do something like this.

          
          model = Sketchup.active_model
          entities = model.entities
          layername = entities[entity_index].layer.name
          
          

          or in a for each loop

          
          model = Sketchup.active_model
          entities = model.entities
          entities.each |entity|
            layername = entity.layer.name
          end
          
          

          I have seen the script you mentioned, but it outputs arcs as a series of lines. I am trying to output arcs as arcs.

          1 Reply Last reply Reply Quote 0
          • honoluludesktopH Offline
            honoluludesktop
            last edited by

            Thanks, I will see if I can use your examples. Sorry I wasn't able to help you.

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              I think it sounds like an autocad problem, no? Or do you think you are doing something wrong with the ruby coordinates for the arc that you are getting?

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • T Offline
                timc
                last edited by

                Chris,
                The only problem I'm having is getting the correct start and end angle of the arc, the ArcCurve.start_angle, and ArcCurve.end_angle are not giving me the correct values.

                I'm currently trying to determine these angles myself using the start point and end point of the arc, but I'm having trouble getting it to work consistently.

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  What value is it returning? It is most likely a radian. So you would need to do a start_arc.radian to change it into degrees (or is it start_arc.degree?). Perhaps that is the issue?

                  Chris

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    timc
                    last edited by

                    I guess I should have said that I already convert it to degrees.

                    I think I am losing something in the transition from sketchup to dxf, but I'm not sure what. It seems like it should be a straight forward transition center point = center point, radius = radius, angles = angles, but it is turning into a real headache.

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      timc
                      last edited by

                      I'm getting closer. It turns out that ArcCurve.start_angle is always 0.0, so I made a function that finds the actual start anlge, I then add that to the end angle for output.

                      
                      def get_new_angle(center, point)
                      #center is the center point returned by AcrCurve.center
                      #point is the start point of the arc returned by ArcCurve.vertices[0].position
                      
                      	return Math;;atan(((center.y.to_f - point.y.to_f)/(center.x.to_f - point.x.to_f))).to_f.degrees.abs
                      end
                      
                      

                      Now the problem is arcs on the y axis are not correct.

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

                      Advertisement