Creating a face inside a face

Using Ruby, I can’t create a face inside a face. Here’s a very simple example, trying to create a circle face inside a square. The final add_face fails. Shouldn’t that work?

ents = Sketchup.active_model.entities
group = ents.add_group
square = group.entities.add_face [0, 0, 0], [5, 0, 0], [5, 5, 0], [0, 5, 0]
center = [2.5, 2.5, 0]
norm = [0, 0, 1]
radius = 2
num_edges = 24
circle_edges = group.entities.add_circle(center, norm, radius, num_edges)
circle_face = group.entities.add_face(circle_edges)

Try drawing the ‘hole’ face first then make the ‘donut’ face around it…

1 Like

Thanks! That works, but it seems strange it doesn’t work the other way too.

It’s just one of those coding things !
If you were to do it the other way round you then need to do a lot of intersecting to pierce the hole and then recover the reference to its face/edges etc…
Best to do it the simplest way…

1 Like

So to put a hole in a preexisting faceA it seems I have to:

  1. save faceA properties and attributes.and existing holes
  2. erase faceA
  3. add the hole faceB (and any other original holes)
  4. readd faceA.and set all its properties.
  5. erase all hole faces.

Also I wonder what happens when I use face.pushpull onto another parallel face. Will that create a hole? or do I have to recreate that one also?


Add the hole face as a group (within the original face group).
Then explode it.
Explode returns an array or edges and a face.
Erase the face.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.