SketchUcation Premium Membership

 

 

One Face that Should Be Two...

One Face that Should Be Two...

Postby kwalkerman » Fri Jun 29, 2012 5:25 pm

Hi,

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.
should be two faces.JPG


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).

Any ideas?

Thanks!

--
karen
Please, register (free) to access all the attachments on the forums.
kwalkerman
 
Posts: 135
Joined: Mon Feb 08, 2010 9:48 pm
Name: Karen

Re: One Face that Should Be Two...

Postby TIG » Fri Jun 29, 2012 9:12 pm

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...
TIG
User avatar
TIG
Global Moderator
 
Posts: 13998
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: One Face that Should Be Two...

Postby TIG » Sat Jun 30, 2012 8:58 am

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=ents.add_group()
ents.each{|e|tgp.entities.add_line(e.vertices)if e.is_a?(Sketchup::Edge)&&e.faces[2]}
tgp.explode if tgp.entities[0]


It's 'untested', but you get the idea...
TIG
User avatar
TIG
Global Moderator
 
Posts: 13998
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: One Face that Should Be Two...

Postby Dan Rathbun » Sat Jun 30, 2012 9:23 am

Just wonderin' as we were discussing this in another topic...

... would Sketchup.send_action("fixNonPlanarFaces:") do anything in this case?
User avatar
Dan Rathbun
Top SketchUcator
 
Posts: 4087
Joined: Tue Oct 06, 2009 3:06 am
Location: Florida, USA
Name: Dan Rathbun
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: education
Level of SketchUp: Advanced

Re: One Face that Should Be Two...

Postby kwalkerman » Tue Jul 03, 2012 5:27 pm

... 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.

--
Karen
kwalkerman
 
Posts: 135
Joined: Mon Feb 08, 2010 9:48 pm
Name: Karen

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Keyframe Animation plugin - animate your SketchUp model by adding movement to any object.

Premium Members get 20% discount!

Ad Machine
Robot
 
Posts: 2012


Return to Developers' Forum

Who is online

Users browsing this forum: Mike Lucey, Renderiza and 5 guests