Ruby script to rotate a shape using a arc
-
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 pathand 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

-
Followme needs careful configuration to make a proper form...
Why not make the face arc + two radii and pushpull it? -
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.
-
Followme for such fixed rotations like this will often fail and the resulting form won't be 'square' as desired - however, see my
ExtrudeEdgesByLathetool [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... -
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
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