Filling holes between faces after drawing 2 faces

hello everyone,
i’m creating a sketchup ruby plugin to draw faces using height,width and length, but as you can see in the picture bellow when i draw the 2 faces A in the blue model manually automatically the hole between the two is closed but when i add 2 faces B in the green model using the add_face function it doesn’t close it, but i draw the yellow line manually in the green model the hole closes.
can any one help how can i close that hole by ruby code ? like when i draw the faces manually ?
thnx a lot in advance.

I will assume you have a reference to the “yellow” edge:


See: Sketchup::Edge#find_faces()

no the yellow edge i’ve just draw it in the picture to explain more my problem

It doesn’t matter. What I said is the solution.

So you will need to get a reference to one of the hole’s edges (it doesn’t matter which,) so that you can call find_faces() upon it.

It will not hurt to call find_faces() upon all edges of any new face you create:

  face = entities.add_face( pts )
  face.edges.each {|edge| edge.find_faces }
1 Like

awesome thank you so much for your help

i tried your method but it doesn’t seem to work the hole is still there, even if i called find_faces on all edges of the new faces in the picture above referred to as B.

How about posting a test model and a code snippet ?

1 Like

oky that’s a code snippet and the model :

  model = Sketchup.active_model
  entities = model.entities  
      pts[0] = [100, 0, h1]
      pts[1] = [w+100, 0, h1]
      pts[2] = [w+100, w, h1]
      pts[3] = [100, w, h1]
   face = entities.add_face pts
   face.edges.each {|edge| edge.find_faces}

          pts[0] = [100, w, h2]
          pts[1] = [w+100, w, h2]
          pts[2] = [w+100, 2*w, h2]
          pts[3] = [100, 2*w, h2]
       face = entities.add_face pts
       face.edges.each {|edge| edge.find_faces}

faces_holes.skp (104.5 KB)

You have faces reversed (inside-facing-out.)

And I think that the order of points may be passed to add_face() may be reversed.

When I reverse the faces manually, then select evrything and run:

ss = Sketchup.active_model.selection
ss.grep(Sketchup::Edge) {|e| e.find_faces }

… the face on the bottom is made, but not the hole between your new faces.

1 Like

yeah same only the bottom is created why is that ? i changed the order of points given to add_face but it still not reversed ? how can i reverse all face ?

your supplied model isn’t accurate enough…

change to mm and 6 decimals and check the side heights…


it worked thank you so much for your help everyone, there a little space between the roof and faces.

part of the problem is your defining the conversion to model units…

2*39.37 == 2.m.to_inch
=> false

2.m.to_inch == 78.74015748031496



So the hole’s edges were not co-planar ?

yes there was a small space between the roof named A and the vertices of the walls underneath it