• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Creating Arcs

Scheduled Pinned Locked Moved Plugins
7 Posts 3 Posters 625 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.
  • H Offline
    honoluludesktop
    last edited by 14 Sept 2010, 13:33

    Anyone have problems with @entities.add_arc, and selection.add_arc ? I am using Acad's dxf definition of arc for starting, and ending angle, but am getting a circle, not an arc.

    vector = Geom;;Vector3d.new 0,0,1  
    @vector2 = Geom;;Vector3d.new 1,0,0  
    @vector3 = vector.normalize! 
    .
    .
    .
    my_arc = @entities.add_arc [@entity[0],@entity[1],@entity[2]], @vector2, @vector3, @entity[3], @entity[4], @entity[5], 24
    

    Am I too tired to see the obvious?-) Hanging it up, and going to bed.

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 14 Sept 2010, 13:59

      Check the data you are feeding the method.

      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
        TIG Moderator
        last edited by 14 Sept 2010, 14:05

        There is only a entities.add_arc(...) method - there isn't one for 'selection' 😕

        TIG

        1 Reply Last reply Reply Quote 0
        • H Offline
          honoluludesktop
          last edited by 14 Sept 2010, 16:57

          Thanks tt, and oops about my own typo TIG. I meant to write status = entities.add_selection my_arc, where my_arc = @entities.add_arc [@entity[0],@entity[1],@entity[2]], @vector2, @vector3, @entity[3], @entity[4], @entity[5], 24.>_<

          1 Reply Last reply Reply Quote 0
          • H Offline
            honoluludesktop
            last edited by 17 Sept 2010, 04:49

            Finally got back to this, and checked data as suggested. I had to rotate the normalized z and x axis, and convert my data to radians. Too bad the API is not set up for beginners, or Architects:-) Now on to calculate the default number of line segments for arcs.

            my_arc = @entities.add_arc [@entity[0]+@block_x,@entity[1]+@block_y,@entity[2]+@block_z], @vector2, @vector3, @entity[3], @entity[4]*(Math::PI/180), @entity[5]*(Math::PI/180), 24

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 17 Sept 2010, 06:13

              There are methods to convert between degrees and radians:
              http://code.google.com/apis/sketchup/docs/ourdoc/numeric.html

              From radians to degrees:
              1.22.radians

              From degrees to radians:
              30.degrees

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

              1 Reply Last reply Reply Quote 0
              • H Offline
                honoluludesktop
                last edited by 22 Sept 2010, 14:14

                Well, I finally took the time to make this really work. Starting and finishing angles are measured in radians, measured counter clockwise from the +x axis. I needed to add 360 to the finishing angle.

                When:
                vector = Geom::Vector3d.new 0,0,1 @vector2 = Geom::Vector3d.new 1,0,0 @vector3 = vector.normalize!
                The correct arc is drawn by:
                my_arc = @entities.add_arc [@entity[0]+@block_x, @entity[1]+@block_y, @entity[2]+@block_z], @vector2, @vector3, @entity[3], (@entity[4]*Math::PI)/180, ((360+@entity[5])*Math::PI)/180

                @block_? is the location of the block/group from the origin. When an entity, its value is 0.0, nothing.

                Only problem now, is that the data from my Cad's DxfOut, and Acad's seems to be different. I have to check the spec. by their version numbers, but I can't believe they have changed that much.>_< But "Oh well", that's why I am writting this s*^&&y app.:-)

                Addenda: I found this variable tags 210, 220, and 230 (extrusion direction) wherein my Cad's DxfOut is [0,0,-1], and the default Acad's is [0,0,1]. What's an extrusion direction?

                Addenda: z=-1 in [x,y,z] seems to mean that the arc is mirrored around the world view origin. It appears that when z=1 in [x,y,z], the arc is mirrored on the y axis, and set by (see the green (-)) below:
                my_arc = @entities.add_arc [%(#008000)[-]@entity[0]+@block_x, @entity[1]+@block_y, @entity[2]+@block_z], @vector2, @vector3, @entity[3], (@entity[4]*Math::PI)/180, ((360+@entity[5])*Math::PI)/180

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

                Advertisement