[Plugin] Face Flattener 0.19

[Plugin] Face Flattener 0.19

Postby cerevellum » Thu Jun 19, 2008 9:38 pm

Hey,

I have made a script to simplify models or correct geometry that is close to coplanar and making it coplanar. Currently the script flattens geometry either to a plane with a normal of (0,0,1) - facing straight up - or (X,Y,0) - facing straight out - and after you flatten to an initial (X,Y,0) direction all else will follow either parallel or perpendicular (90 degrees) to that initial flatten. Faces with a normal within 30 degrees of (0,0,1) will flatten to a plane that just faces straight up, where all else flattens straight out. These settings can be adjusted within the code.

The order of operations:
1. Select some geometry
2. Right click, select Flattening Script
3. Left click on a face (this decides the plane the geometry will project to)





Thanks,
Zach
0
User avatar
cerevellum 
 

Re: [Plugin] Face Flattener 0.19

Postby lewiswadsworth » Thu Jun 19, 2008 9:46 pm

Thanks, Zach. I was actually thinking about a script like this, fond as I am of the similar "Setpt" command in Rhino.
0

lewiswadsworth 
 

Re: [Plugin] Face Flattener 0.19

Postby dylan » Thu Jun 19, 2008 10:31 pm

Thanks Zack.
This could prove really useful for the bad AutoCad imports I sometimes get.
0

dylan 
 

Re: [Plugin] Face Flattener 0.19

Postby matteo » Thu Jun 19, 2008 11:49 pm

Thank you. This may become one of the most used scripts in my daily work.
0

matteo 
 

Re: [Plugin] Face Flattener 0.19

Postby kwistenbiebel » Thu Jun 19, 2008 11:53 pm

I love the idea!
Can it also remove the unneeded edges afterwards , so we have clean geometry to push pull?
0

kwistenbiebel 
 

Re: [Plugin] Face Flattener 0.19

Postby cerevellum » Fri Jun 20, 2008 12:20 am

No problem, glad it could be useful to some!

So, in fact there is more functionality to this script, but a lot of the methods are not being used currently. I need to get it up to speed, maybe over the weekend. Basically, if you intersect with model you can erase the inside edges, and I'm working on getting them to remove automatically. The methods are all in the script, they just need to be called, and in the right order (what I have been struggling with).

Anyway, feel free to play around with the script. I'll do my best to update it, too.

Thanks again,
Zach
0
User avatar
cerevellum 
 

Re: [Plugin] Face Flattener 0.19

Postby Mike Lucey » Fri Jun 20, 2008 12:21 am

Thanks Zach,

This looks like the Ruby that we talked about at the
Hotel Avante, very useful indeed.

Be sure to get your Avatar up there soon and don't be
a stranger :)

Best,

Mike
0
User avatar
Mike Lucey 
Mayor
 

Re: [Plugin] Face Flattener 0.19

Postby RayOchoa » Fri Jun 20, 2008 2:25 am

Dang, Sketchup is starting to look more and more like CAD programs like Wings3d and Rhino. he he its going to end up as complicated too. All it needs now is faster control over high poly models
0
CaR DeSiGnS bY mE
http://ray-ochoa.com
User avatar
RayOchoa 
 

Re: [Plugin] Face Flattener 0.19

Postby rv1974 » Fri Jun 20, 2008 4:15 am

@Rayochoa:
This is a PLUG-IN. If you don't need it simply don't plug it.
IMHO it has a good potential. And if this tool will help me to save a couple of hours per year so why not?
0

rv1974 
 

Re: [Plugin] Face Flattener 0.19

Postby cyan.archnet » Fri Jun 20, 2008 4:45 am

thanks a lot for the plug-in, sure a big help!!
0

cyan.archnet 
 

Re: [Plugin] Face Flattener 0.19

Postby Jackson » Fri Jun 20, 2008 8:42 am

Zach- thanks for this ingenius ruby, can't wait to give it a try!
0
Jackson

Jackson 
 

Re: [Plugin] Face Flattener 0.19

Postby plot-paris » Fri Jun 20, 2008 8:47 am

nice tool. I am definittely in danger of flattening every model I can lay my hands on (my colleagues won't like that ;) ).

I am looking forward to the "auto-cleanup" version.

cheers,

Jakob
0
User avatar
plot-paris 
 

Re: [Plugin] Face Flattener 0.19

Postby RayOchoa » Sat Jun 21, 2008 3:37 pm

rv1974 wrote:@Rayochoa:
This is a PLUG-IN. If you don't need it simply don't plug it.
IMHO it has a good potential. And if this tool will help me to save a couple of hours per year so why not?

I didin't say i didn't like it i said that all these plugins are taking sketchup very far. But hey i like this better, rather than learning everything at the same time little by little is way better
0
CaR DeSiGnS bY mE
http://ray-ochoa.com
User avatar
RayOchoa 
 

Re: [Plugin] Face Flattener 0.19

Postby RayOchoa » Sat Jun 21, 2008 3:40 pm

U maybe wan't to take a look at this
0
CaR DeSiGnS bY mE
http://ray-ochoa.com
User avatar
RayOchoa 
 

Re: [Plugin] Face Flattener 0.19

Postby MALAISE » Sat Jun 21, 2008 5:05 pm

:D Thanks a lot

What a waste of time I got, trying to understand why theses blood... lines didn't made a surface.
friendly :ecstatic: MALAISE
( sorry for my approximative english )
0
La Connaissance n'a de valeur que partagée
User avatar
MALAISE 
 

Re: [Plugin] Face Flattener 0.19

Postby watkins » Sat Jun 21, 2008 6:13 pm

Dear Ray,

I tried out your script on the following simple model.

Draw a rectangle, say 100 mm by 100 mm, and then pull it up 10 mm into a 3D shape.
Use the move tool to pull up one corner on the top face by 0.1 mm.
Draw a few lines on the sides to divide areas into two, and perhaps a few random, un-terminated lines on various surfaces.
Select all and run your script.

When I do this I lose the top face. Interestingly enough this also happens when I run the script cleanup_model.rb (by John H. Aughey). The script deletecoplanaredges.rb (by Jack Dolabany)removes all redundant co-planar lines, but leaves the top face with its centre fold untouched.

I imagine that this is not what you had in mind.

Kind regards,
Bob
0

watkins 
 

Re: [Plugin] Face Flattener 0.19

Postby rcossoli » Sat Jun 21, 2008 7:46 pm

thanks, will be very useful
0

rcossoli 
 

Re: [Plugin] Face Flattener 0.19

Postby cerevellum » Sat Jun 21, 2008 8:40 pm

Hi Ray and Bob,

This is something I've noticed while working on my flattening script, and I still haven't figured out why it happens. The simplest way of reproducing this is to draw a box, add a rectangle to the top surface and connect it with a line to the outer edge loop. When erasing one of the edges of the rectangle that was added, both faces disappear.

edgeFaceEraseExFinalA.jpg


However, if you were to erase the edge that connects both edge loops first, then you can erase the edges of the inside rectangle just fine. It apparently has to do with the order in which you erase coplanar edges. Delete edges in the following order: edges connected to 0 faces go first, then edges connected to 1 face, and finally edges connected to 2 faces.

edgeFaceEraseExFinalB.jpg


See ya,
Zach
0
User avatar
cerevellum 
 

Re: [Plugin] Face Flattener 0.19

Postby watkins » Sat Jun 21, 2008 9:45 pm

Dear Zach,

The script deletecoplanaredges.rb failed your example too, so some recoding is needed to get a more reliable cleanup script.

Regards,
Bob
0

watkins 
 

Re: [Plugin] Face Flattener 0.19

Postby Gaieus » Sun Jun 22, 2008 7:33 am

cerevellum wrote:Hi Ray and Bob,

This is something I've noticed while working on my flattening script, and I still haven't figured out why it happens. The simplest way of reproducing this is to draw a box, add a rectangle to the top surface and connect it with a line to the outer edge loop. When erasing one of the edges of the rectangle that was added, both faces disappear...

Ha! Beautiful! I love these "glitch hunts". And you cannot even heal the face by redrawing an edge of it until you get rid of the leftover geometry in the middle! :thumb:
0
User avatar
Gaieus 
 

Re: [Plugin] Face Flattener 0.19

Postby watkins » Sun Jun 22, 2008 7:59 am

Dear Gaieus,

Perhaps some of our script writers could come up with a more reliable clean-up script.

I note from Zach's example that the line joining the inner and outer loops is bounded by the same area, while the lines forming the inner and outer loops are bounded by different areas. What makes an area/surface unique, and could this be used to decide on the order of line removal? At least deletecoplaredges.rb leaves the centre fold line in an non-coplanar surface alone, and so perhaps this would be the script to start with. A nice icon would not go amiss, say an image of a few random, crossed lines.

Kind regards,
Bob
0

watkins 
 

Re: [Plugin] Face Flattener 0.19

Postby Gaieus » Sun Jun 22, 2008 8:10 am

Bob, Zach,

I have a script that creates a menu item "Remove unused edges" in the Edit menu (for the life I cannot locate the script anywhere to see the file name of it). Using the script it also deletes the top surface (so the order it deletes the lines must be wrong as well).

I have noticed a couple of times that using it leads me to lose a coupleof faces (especially after complex, curved intersections).
0
User avatar
Gaieus 
 

Re: [Plugin] Face Flattener 0.19

Postby watkins » Sun Jun 22, 2008 8:31 am

Dear Gaieus,

It is cleanup_model.rb.

Regards,
Bob
0

watkins 
 

Re: [Plugin] Face Flattener 0.19

Postby Gaieus » Sun Jun 22, 2008 10:19 am

Ah, thanks a bunch, Bob! I have always wondered and couldn't figure out (I keep a fairly nice mess in my Plugins folder).
0
User avatar
Gaieus 
 

Re: [Plugin] Face Flattener 0.19

Postby RayOchoa » Mon Jun 23, 2008 1:31 am

You know what i don in order to get a 2d model is get the scale tool and type in .002 and then do that again by putting a line next to it and resizing again. then i just erase the lines i want after intersecting everything
0
CaR DeSiGnS bY mE
http://ray-ochoa.com
User avatar
RayOchoa 
 

Re: [Plugin] Face Flattener 0.19

Postby rv1974 » Mon Jun 23, 2008 6:02 am

:!: Perfect solution: export-import 2D hidd.line mode dwg.
Not sure it canbe implemented in .rb though
1

rv1974 
 

Re: [Plugin] Face Flattener 0.19

Postby Fletch » Mon Jun 23, 2008 4:55 pm

RE: Face flattener - I'll give it a shot... thanks for sharing!

Ray, and others, when wanting to export a flat model from SU to CAD format - don't forget the Automated 2D Output ruby! Then you can just re-import the .dwg file back into SU, and it will be flat.
0

Fletch 
Twilight Render
 

Re: [Plugin] Face Flattener 0.19

Postby zhuangsuph » Tue Aug 05, 2008 12:33 pm

:berserk: :berserk: :berserk:
0

zhuangsuph 
 

Re: [Plugin] Face Flattener 0.19

Postby wzfwzfwzf » Wed Aug 06, 2008 3:46 am

hehe,hello.
0

wzfwzfwzf 
 

Re: [Plugin] Face Flattener 0.19

Postby fredo6 » Wed Aug 06, 2008 10:30 pm

cerevellum wrote:Hi Ray and Bob,

This is something I've noticed while working on my flattening script, and I still haven't figured out why it happens. The simplest way of reproducing this is to draw a box, add a rectangle to the top surface and connect it with a line to the outer edge loop. When erasing one of the edges of the rectangle that was added, both faces disappear.



What you can try to possibly avoid this problem is to calculate all coplanar segments, not delete them, but instead put them in a list (or in the selection). Then, just delete the entities in the list (or in the selection):
Code: Select all
model.entities.erase_entities list_edges
#or
model.entities.erase_entities model.selection


It seems to work fine on your example, and on some more complex configurations, but I did not try in the general case.

Note: manually in Sketchup, what I would use is to select all coplanar segments, put them in a group and then just delete the group. It leaves all faces intact. Unfortunately, there is no method in Ruby to make a group or a component out of existing elements!
1
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: Google Bot and 19 guests

Visit our sponsors: