api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

"add_face" Creates Extra Edge

Open NeilBurkholder opened this issue 4 years ago • 8 comments
trafficstars

When creating a face with an edge that is in exactly the same place as two shorter edges, a new long edge is used instead of using the existing short edges. This results in geometry that is non-solid.

Here is the code to reproduce the issue.

def clear_model
  Sketchup.active_model.entities.clear!
  Sketchup.active_model.definitions.purge_unused
end

def test_non_solid
  d = Sketchup.active_model.definitions.add("Non-Solid")
  Sketchup.active_model.entities.add_instance(d, IDENTITY)
  d.entities.add_face([5, 0, 10], [5, 10, 10], [0, 10, 10], [0, 0, 10])
  d.entities.add_face([5, 0, 10], [5, 10, 10], [10, 10, 10], [10, 0, 10])
  d.entities.add_face([0, 0, 10], [0, 10, 10], [0, 10, 0], [0, 0, 0])
  d.entities.add_face([10, 0, 10], [10, 10, 10], [10, 10, 0], [10, 0, 0])
  d.entities.add_face([0, 10, 10], [10, 10, 10], [10, 10, 0], [0, 10, 0])
  d.entities.add_face([0, 0, 10], [10, 0, 10], [10, 0, 0], [0, 0, 0])
  d.entities.add_face([0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0])
end

def test_solid
  d = Sketchup.active_model.definitions.add("Solid")
  Sketchup.active_model.entities.add_instance(d, Geom::Point3d.new(0, 20, 0))
  d.entities.add_face([0, 0, 10], [0, 10, 10], [0, 10, 0], [0, 0, 0])
  d.entities.add_face([0, 10, 10], [10, 10, 10], [10, 10, 0], [0, 10, 0])
  d.entities.add_face([10, 0, 10], [10, 10, 10], [10, 10, 0], [10, 0, 0])
  d.entities.add_face([0, 0, 10], [10, 0, 10], [10, 0, 0], [0, 0, 0])
  d.entities.add_face([0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0])
  d.entities.add_face([0, 0, 10], [0, 10, 10], [5, 10, 10], [5, 0, 10])
  d.entities.add_face([5, 0, 10], [5, 10, 10], [10, 10, 10], [10, 0, 10])
end

def do_tests
  clear_model
  test_non_solid
  test_solid
end

Here are the results:

image

NeilBurkholder avatar Feb 12 '21 13:02 NeilBurkholder

I've noticed this issue for several versions of SU. Some 3D programs I worked with could export a 'model' as a plane list, each defined by its vertices.

Some would minimize the number of vertices, so in the cube shown above, the top would be two planes, and the facing side, being a square, would have four vertices.

MSP-Greg avatar Feb 12 '21 14:02 MSP-Greg

I wonder, does Fix Model fix anything? Or does it think everything is just fine?

thomthom avatar Feb 12 '21 14:02 thomthom

Clicking Info shows this message:

image

Clicking Fix All shows this:

image

NeilBurkholder avatar Feb 12 '21 14:02 NeilBurkholder

Its been a while...

I wonder, does Fix Model fix anything?

I did write code to show the problem edges. So I assume not.

'could not be automatically fixed'

I think I did the above because I concluded that it required 'user intervention', iow, code couldn't fix them. Right now, I don't recall why.

EDIT: The external programs I was working with had issues with what I'd call 'donuts' and 'sliced donuts' (various forms of a face being bounded by concentric edges), that may have been part of the reason I couldn't fix them in code...

MSP-Greg avatar Feb 12 '21 14:02 MSP-Greg

@NeilBurkholder - I mean from Model Info > Statistics. SketchUp's own model validity check.

thomthom avatar Feb 12 '21 15:02 thomthom

No

image

NeilBurkholder avatar Feb 12 '21 15:02 NeilBurkholder

Logged as: SKEXT-2916

sketchupbot avatar Feb 15 '21 07:02 sketchupbot

Hi NeilBurkholder,

As part of reproducing old bugs, I encountered this one, looks like this has been fixed in versions SU2023.1 , SU2024.0 and SU2025.0 Could you please confirm the same?

Thank you

kalpana-ghodeswar avatar May 15 '25 16:05 kalpana-ghodeswar