5 posts • Page 1 of 1
I have code that takes loose geometry, groups it, intersects it and then does something with the pieces. Most of the time everything is groovy, but I'm having an issue I'm not sure how to resolve. In the image, you can see that the selected face is one face that "should" be two.
I've tried intersecting entities, doing "edge.find_faces" on all the face's edges, but I haven't come up with a good solution yet (short of deleting the face and re-creating it, but that could cause other issues).
Please, register (free) to access all the attachments on the forums.
It is known...
This sometimes occurs when complex 2d shapes intersect.
My fix is add a short [referenced] temp-edge inside a temp-group, set perpendicular to the face [face.normal] at each of the face.vertices.
You can perhaps now make each edge have zero length [make its two vertices share the same point] BUT you can skip this step if you are sure there's no risk of geometry clashes in the face.parent context when the edge's temp-group is exploded.
Then explode each edge's temp-group in turn.
Now try to erase each temp-edge in turn [it might not now exist... so trap for failure with e.valid?]...
This method should now split the face.edges at any cross-threaded 'bow-tie' vertices.
Making the faces as two separate entities, each with its own loop...
The nesting of these methods can be quite convoluted, BUT it will fix it...
My solution of yesterday was made from a similar 2d face issue.
However, my brain must have carried on working while I slept!
As this is a 3d problem it's easier: after you intersect everything it might split some intersecting faces [here vertical 'red'] but leave the top/bottom faces as 'bow-ties' [here green], but we can find any edges with 4 faces instead of 2 [which incidentally means its no longer a 'solid', every edge in a manifold solid must have exactly 2 faces] and then just update those with an explode ? Something like this [assuming 'ents' is the entities context containing the faces/edges]...
tgp.explode if tgp.entities
It's 'untested', but you get the idea...
Just wonderin' as we were discussing this in another topic...
... would Sketchup.send_action("fixNonPlanarFaces:") do anything in this case?
... I should've saved the file with the messed up face to try it on!
I ended up with something similar to TIG's suggestion,except that I found any vertices referenced more than two edges on the same face. Then I was able to re-create the faces using the original face's vertices.
5 posts • Page 1 of 1