I’ve encountered some unexpected (and undesired) behavior in the Ruby API, and I’m looking for some help understanding it, and circumventing it.
When I add an edge, then add another edge which has a vertex that lies on the first edge, the first edge gets split into two edges. I see why this would be useful in some circumstances, but it’s not what I want to happen in this case. I did some research, and found that setting “Sketchup.break_edges = false” should fix it. However, I was surprised to find that seems to have no effect!
Any idea why this is happening, and how I can get around it? I don’t want the first edge to get split!
I’ve included some code that you can copy/paste into your SketchUp Ruby console that demonstrates the problem:
# Start with empty model model = Sketchup.active_model entities = model.entities puts('Start with an empty model.') puts('No entities, see?') puts('entities.to_a :') puts(entities.to_a) Sketchup.break_edges = true puts('Creating two lines, with one with a vertex on the other:') line0 = entities.add_line([0, 0], [100, 0]) line1 = entities.add_line([50, 0], [50, 50]) puts('There should now be three edges, since the second edge split the first into two edges') puts(entities.to_a) puts('Clearing model') entities.erase_entities(entities.to_a) puts('Now let us try this with Sketchup.break_edges=false :') Sketchup.break_edges = false puts('Creating two lines, with one with a vertex on the other:') line0 = entities.add_line([0, 0], [100, 0]) line1 = entities.add_line([50, 0], [50, 50]) puts('Now I would expect there to be only two edges, since Sketchup.break_edges = false. However, there are three entities again! The second edge split the first, despite break_edges = false') puts(entities.to_a)
OS: macOS Sierra 10.12.6
SketchUp version: SketchUp Pro 2018