Face can not be separated when has only one vertices on the edge


#1

hi,dear all

as the picturess, when there is only one vertices on the edge or in the same vertices, the bigger face can not be separated.

I would like to get the bigger face which subtracted by the small one face in picture1

how can I get that?

thank you for your help


#2
es=Sketchup.active_model.selection.grep(Sketchup::Edge)
# or grep the entities context containing the faces/edges
es.each{|e|next unless e.faces.length==1;e.faces[0].erase!}
es.each{|e|e.find_faces}

This finds edges with one face and erases that face, it then adds faces to the edges.

Another way would be to erase the ‘outer’ face and re-add it…

Usually when making a ‘donut’ in the API you should make the ‘hole’ first [getting a reference to it as you do so], then add the outer face [ignoring the hole].
Then delete the remembered ‘hole’ face…
If you want that face too, then re-add it again and it should separate…


#3

it seems like a bug.

yes ,as you say, when I draw small face use pencil tool, and use rectangle tool to draw big one ,it works.

but in this situation, it seems there is no idea to handle it

mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
pts1=[[50,0,0],[50,50,0],[75,50,0]]
pts2=[[0,0,0],[0,100,0],[100,100,0],[100,0,0]];
fc1 = ent.add_face(pts1);
fc2 = ent.add_face(pts2);
ent.erase_entities([fc1]);

no use at all.

or like this

es = fc1.edges
es.each{|e|next unless e.faces.length==1;e.faces[0].erase!}
es.each{|e|e.find_faces}

or like this

es = fc2.edges
es.each{|e|next unless e.faces.length==1;e.faces[0].erase!}
es.each{|e|e.find_faces}

all of these do not work. the behavior just like they are in 2 different groups without any ralationship.

headache


#4

but if you change pts1 to

pts1=[[50,0.001,0],[50,50,0],[75,50,0]] , The situation changes… what I do,just move the pt ,up to 0.1 inch, following the Y Axis.

mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
pts1=[[50,0.1,0],[50,50,0],[75,50,0]]
pts2=[[0,0,0],[0,100,0],[100,100,0],[100,0,0]];
fc1 = ent.add_face(pts1);
fc2 = ent.add_face(pts2);
ent.erase_entities([fc1]);


#5

It is a long know bug, not just in the API but in SketchUp itself.
Try drawing the shape manually and the one-touch triangle does not merge with the rectangle.

The reason your last example works is because the triangle no longer touches the rectangle’s edges.

In your previous example you did not try the version that works !

mod = Sketchup.active_model
ent = mod.active_entities # All active entities in model OR inside a group to separate things
sel = mod.selection # Current selection
pts1=[[50,0,0],[50,50,0],[75,50,0]]
pts2=[[0,0,0],[0,100,0],[100,100,0],[100,0,0]]
fc2 = ent.add_face(pts2)
fc1 = ent.add_face(pts1) # reverse order of creation
es = fc1.edges + fc2.edges
es.uniq!
es.each{|e| next unless e.faces.length==1; e.faces[0].erase! }
es.each{|e| e.find_faces }

#6

it works, thank you very much! It’s very nice of you!

I am new to SU, no more than 2 months. so I will ask some stupid questions, thanks for kindness.

Hoping the bug will be fixed ASAP as it’s the long know bug.


#7

Alas, the fact that it is long known reflects that it is so deeply entangled in the code logic that they think it will take a lot of effort to fix. They have chosen to put priority elsewhere for several releases of SU.