When drawing shapes from the GUI, it seems that faces are filled in more automatically than when creating the shapes from ruby. When producing shapes from ruby, when should I expect a face to be created automatically? And when a face exists, and I draw lines through it, when and how should it be sliced up into individual faces?
In this short example, I create a hexagon, fill it in with a face and then draw a circle inscribed inside the hexagon. This is the part of constructing a nut or bolt. I would hope and expect that the face would be sliced up into one new circular face and 6 small triangular faces around the perimeter. But this does not happen. What is worse, is that one triangle does get sliced off. This seems a bit random to me and I’m not sure why or how to create predictable behavior.
Is this because the points of the circle don’t line up exactly with the bisectors of the hexagon segments (i.e. very small floating point errors)? Or is there something else going on?
To see the problem, run this script and then try selecting faces on the plane. Notice that if you create the inscribed circle from the GUI, the face gets sliced up correctly. It is only when I create the circle from ruby that it doesn’t work right? Is there some kind of “cleanup” routine that gets called when using the GUI to check existing faces for bisecting lines?
#Test problem with intersecting points require 'sketchup.rb' model = Sketchup.active_model ents = model.entities w = 1.625 #Width from flat to flat on hex r = (w / 2 / Math.cos(30.degrees)) #Radius of inscribed circle n = ents.add_ngon([0,0,0], [0,0,1], r, 6) #Make the hexagon f = ents.add_face(n) #Fill in with a face c = ents.add_circle([0,0,0], [0,0,1], w/2, 12) #Make inscribed circle