sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Ruby script to rotate a shape using a arc

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    5 Posts 2 Posters 363 Views 2 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.
    • W Offline
      wsellers89
      last edited by

      Sorry to ask such an elementary question, and I hope that this is the right forum. I am working my way through ruby scripting and wanted to rotate a simple surface such as a rectangle to form half a cylinder. It is extremely important that the edges of the cylinder match up with the x-axis, so I used an arc going from 0 to 90 degrees. When the script rotates the rectangle it does something strange in that it appears to over rotate (look near the origin). The script is as follows:

      # Access the Entities object
      model = Sketchup.active_model
      ents = model.entities
      
      # Create the 2-D shape
      curve = ents.add_curve [5, 0, 0], [15, 0, 0],
      [15, 0, 10], [5, 0, 10], [5, 0, 0]
      curve_face = ents.add_face curve
      
      # Create the arc path
      path = ents.add_arc [0, 0, 0], [0, 0, 1], [1, 0, 0], 5, 0.0, 180.degrees
      
      # Create the figure
      curve_face.followme path
      

      and I will attach an image of what resulted. I do know that if I draw a rectangle on the x-axis and intersect with the rotated object it does line up, but why the strange behavior? Am I missing something simple?

      Sincerely,
      Bill


      Rotated rectangle.  Rectangle is 10 units long and 10 units high starting at x= 5

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Followme needs careful configuration to make a proper form...
        Why not make the face arc + two radii and pushpull it?

        TIG

        1 Reply Last reply Reply Quote 0
        • W Offline
          wsellers89
          last edited by

          Dear TIG,

          Because what I was ultimately heading toward was the ability to take a complicated profile (Versus a rectangle) and rotate it exactly 180 degrees. The profile could be something like a cross section of a rocket launcher or a cross section of a jet engine, which wouldn't work well with the Push/Pull.

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            Followme for such fixed rotations like this will often fail and the resulting form won't be 'square' as desired - however, see my ExtrudeEdgesByLathe tool [in Extrusion Tools zip] - It takes the profile from a face etc and sweeps it properly through a given [picked or typed in] angle: it's probably too complex for your needs... BUT it can give you lots of clues for making a proper 45/90/180/270/360/etc swept form...

            TIG

            1 Reply Last reply Reply Quote 0
            • W Offline
              wsellers89
              last edited by

              Wow! Thanks for the help and the education regarding what it takes to make it rotate a precise number of degrees. It was way past my skill level!

              Thank you again.

              Sincerely,
              Bill

              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