I have been working with computers for a while, but new to Ruby! I am in awe at the potential ruby and Sketchup bring!
Anyway, as I set out to develop what (I hope) will be some useful tools, I encountered a problem. I am trying to create a sphere, by creating a circle, a face, and having the face “followme” the circle. I started off by offsetting the face from the origin a distance equal to the circle’s radius, creating a torus (it "followme"s the circle nicely). When I start to reduce this offset distance the torus starts to become more sphere-like until, when the distance is something like radius/5, Sketchup blows up and a bug is generated. The code for the successful torus is as follows:
def draw_sphere UI.messagebox "in draw_sphere2" model = Sketchup.active_model entities = model.active_entities radius = 10 centerpoint1 = Geom::Point3d.new( 0, 0, 0 ) vector1 = Geom::Vector3d.new( 0,1,0 ) vector1n = vector1.normalize! circle1 = entities.add_circle centerpoint1, vector1n, radius centerpoint2 = Geom::Point3d.new( radius, 0, 0 ) vector2 = Geom::Vector3d.new( 0,0,1 ) vector2n = vector2.normalize! circle2 = entities.add_circle centerpoint2, vector2n, radius face2 = entities.add_face circle2 face2.followme( circle1 ) end
I imagine this demonstrates some basic ignorance on my part about how this works, but I would like to know how to resolve it. In order to run this, I added an item to my UI.menu(“Plugins”), which seems to work well.