How to repair programmatically this crazy face?

When I select with cross selection one of the three alone edges it also causes the face selection.
Double click on face causes the alone edges selection too.
The face presents tree loops (face.loops.count).
How can I solve the problem programmatically?

crazy face.skp (21,2 KB)

That is certainly a strange and nonsensical situation. How did you create it? What structure were you attempting to make? If you can share the code that produced this, someone may be able to identify how to avoid the issue (there are some known bugs when faces are created touching in certain ways).

To recover, get references to the three offending edges in the dangling, empty inner loop. Then erase them. SketchUp will heal the defective face along the way.

Steve beat me.

It looks like the same issue as this.

Select one of the edges in the inner ‘loop’, and run this code to delete and recreate it.

mod = Sketchup.active_model
sel = mod.selection
ent = mod.entities
e = sel[0]
p1 = e.start.position.to_a
p2 = e.end.position.to_a

Hi, this is my code:

    Sketchup.active_model.entities.grep(Sketchup::Edge).map{|e| e.find_faces}

and here is the starting set of edges:

crazy face 2.skp (18,3 KB)

To reach the similar situation I proposed you can run this row of code too:

Sketchup.active_model.entities.grep(Sketchup::Face).each{|f| (f.erase! if f.loops.count == 1) rescue nil}

This line of code is optional. The first one is enough to create the crazy face.


About the programmatically solution:

How can I identify those edges? They are inside the loops of the face and nothing seems to say that they are “offending edges” for that face!
“Face.edges” retrieves them and “edge.face” retrieves the crazy face!
Is there a programmatically way to identify this kind of mistakes?


There is a situation that I call “Bow Ties” where faces get combined. I use this code to find them

mod = Sketchup.active_model
ent = mod.active_entities
sel = mod.selection
  f.material='red' if f.vertices.length!=f.vertices.uniq.length

Hmmm… When I run this code snippet on your crazy face 2 model, I get the following (which is what I would expect):

Please fill out your profile info - it doesn’t say what year and version of SketchUp you are using, what OS, or what graphics adapter. It could be there is a bug that is version dependent. I’m using 17.2.2554 on a Mac, and perhaps this bug has been fixed (or at least mutated).

I don’t know of a simple way other than selecting via the GUI. You would have to write code that detects this specific “corner case”, and it could be tricky to keep it from catching other cases that aren’t defective. Ironically, I think such code would reveal the logic flaw that causes SketchUp’s method to commit the error in the first place!

Try to select with a cross selection the edge I colored, then deselect only the edge by single deselection click.
After that look at “Entity Info” panel. You’ll see three faces selected. One of them is the “crazy face”.

Now I’ll fill out my profile. I’m using Sketchup Make 17.0.18898 on Mac

That may be an issue: there have been two maintenance releases since 17.0. Try updating to 17.2 (latest) and see if that helps - they may have found and corrected a bug!

Yes it work to identify the crazy face!!

mod = Sketchup.active_model # Open model
    ent = mod.entities # All entities in model
    sel = mod.selection # Current selection
      if f.vertices.length!=f.vertices.uniq.length
        puts f.loops.count

Look at loops.count to see the problem! It retrieves 3 loops instead of 2 !!!

Tnk’s I’ll try!

Hi guys, I updated the sketchup to the latest version but the problem persists. My goal is to create all possible faces from a set of edges. Unfortunately, the command “find_faces” continually generates mad faces! Where am I wrong?
Below is the code I use and the starting file.
In the picture I reported with the number 1 the starting edges, with the 2 I indicate the result of the code and with the 3 I stole the mad faces produced by the code.

Tnk’s all!

ents = Sketchup.active_model.active_entities
ents.grep(Sketchup::Edge).each{|e| e.find_faces }
faces = ents.grep(Sketchup::Face)  
to_regen_faces = []
    if f.vertices.length > f.vertices.uniq.length
      to_regen_faces.push f
## HOW CAN I REGENERATE faces inside to_regen_faces Array ?

crazy faces 3.skp (192,2 KB)


I haven’t tried this [I’m not at a suitable PC], but…
Find all of the made faces, and collect their vertices.
Make a temporary group in the faces’ entities context, and iterate the faces/vertices - with
group.entities,add_line(vertex.position, vertex.position.offset(face.normal))
Now you have a set of 1" lines perpendicular to the face[s], located at every vertex.
edges = group.explode
The exploded edges should now merge with the faces/edges and hopefully split any ‘bow-ties’ ?
The explode gives you the temporary edges collection.
Then use edges.each{|e| e.erase! if e.valid? } to tidy up ?

Might have to do with the single vertex bug ?

Notice that the area’s in the entity info of the inner loops are substracted from the larger ones.


It looks like something similar. I’m trying to find a solution to obtain good faces. TIG’s method doesn’t looks the right way.

Your approach is really smart but doesn’t works. I tryed to generate. Vertical faces too and intersect/explode them but nothing goes better. Now I’m trying to work with meshes to regenerate base faces. Tnk’s anyway!

I noted that is not so difficult to generate this kind of crazy faces simple drowing lines or rettangles via standard tools in 3D window. It is strage that It is not yet resolved and not documented! Even when you push/pull the face the mistake will reflects on 3d geometries!!

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