SketchUcation Premium Membership

 

 

[Plugin] Cleanup (3.1.10) — 18 March 2013

[Plugin] Cleanup (3.1.10) — 18 March 2013

Postby thomthom » Wed Oct 21, 2009 6:36 pm

Overview
This plugin does it best at optimize and clean up a model.



Access
Plugins > CleanUp
CleanUp3_1_Menus.png


Features
  • Fixes duplicate component definition names ( When in model scope )
  • Purge unused items
  • Erase hidden geometry
  • Erase duplicate faces
  • Erase lonely edges ( Except edges on cut plane )
  • Remove edge material
  • Repair split edges
  • Smooth & soft edges
  • Put edges and faces to Layer0
  • Merge identical materials
  • Merge connected co-planar faces

Requirements
  • SketchUp 7.1 or newer - You can run it on older versions, but it will not yield a predictable result - you will be warned about this.
  • TT_Lib2 (v2.7.0)

Installation Information
Guide: How to install RBZ Files


Download


tt_cleanup-3.1.10.rbz


Footprint
<Sketchup>/Plugins/
+-
tt_cleanup.rb

History
Both the Sketchup Importers option too remove coplanar edges and the deletecoplanaredges plugin have given me mixed result. Geometry tend to disappear in some cases. Part of that is due to a Sketchup bug: http://forums.sketchucation.com/viewtop ... 30#p164501 and another part is due to what seem to be some inconstancy with the way Sketchup and the Ruby API deal with numbers.
As of 7.1 the first issue appear to have been fixed. (Yay! :berserk: ) And I have found a work around for the other issue.
If you experience geometry to be lost, while using SU 7.1 - please let me know so I can look into it.

If you have geometry selected it will work on those only. Otherwise it will iterate over the current context.

Technical Jabber
Prior to SU 7.1 there was a bug where in some cases deleting an coplanar edge, either via Ruby or the Eraser tool, would make its connected faces disappear. See this thread for more info and samples: http://forums.sketchucation.com/viewtop ... 30#p164496
I tried to work around that previously, but the code ended up stupidly complex trying to keep track of all the edges I couldn't erase, and no matter what I did I always ended up loosing geometry, or not managing to remove everything. With this issue fixed in SU 7.1 it's now dead easy; Find'em and Erase'em!

Update — 22 April 2010
New and improved method to detect coplanar faces. No more messing about with tolerances. :berserk:

cleanup.png


Please, register (free) to access all the attachments on the forums.
Last edited by thomthom on Tue Nov 10, 2009 9:22 pm, edited 8 times in total.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby Ecuadorian » Wed Oct 21, 2009 6:42 pm

Thank you, man. I have the perfect file to test it. :D
Ecuadorian
 
Posts: 1621
Joined: Thu Jan 15, 2009 10:20 pm
Location: Ecuador
Name: Miguel
Operating system: Windows
SketchUp version: 8
License type: Free
SketchUp use: architecture
Level of SketchUp: Intermediate

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 6:44 pm

Ecuadorian wrote:Thank you, man. I have the perfect file to test it. :D

A particular troublesome file? Please let me know how it goes. Not sure if I've got it fully tuned in yet.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby remus » Wed Oct 21, 2009 6:45 pm

Cheers thom, a very useful script.
remus
 
Posts: 8055
Joined: Fri Nov 30, 2007 8:48 am
Location: UK
Name: remus

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby Ecuadorian » Wed Oct 21, 2009 6:51 pm

:shock: Wow... no more lost faces (as happened with other cleanup scripts), and cleanup is top-notch.
before.jpg

after.jpg


Here it is applied only to the horizontal white borders:
before2.jpg

after2.jpg


You do realize the importance of this script in the history of SketchUp, do you? Thanks again! :thumb:
Please, register (free) to access all the attachments on the forums.
Ecuadorian
 
Posts: 1621
Joined: Thu Jan 15, 2009 10:20 pm
Location: Ecuador
Name: Miguel
Operating system: Windows
SketchUp version: 8
License type: Free
SketchUp use: architecture
Level of SketchUp: Intermediate

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 6:56 pm

Good to see it working on other complex models. I only tried it against one complex one, large triangulated terrain with 80K+ faces. (Though that model had all the potential problems you could run into AFIK.)
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby Jim » Wed Oct 21, 2009 7:05 pm

Ack! it doesn't look at materials?

Oh, and thank you! :thumb:
Jim
Global Moderator
 
Posts: 4126
Joined: Mon Nov 12, 2007 10:13 pm
Location: NEOH
Name: Jim
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: other
Level of SketchUp: Intermediate

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 7:07 pm

Jim wrote:Ack! it doesn't look at materials?

Oh, and thank you! :thumb:

No, but that's a very good suggestion.

Ecuadorian did find some issues with some geometry, so I'll push an update when I've gotten around to look at it.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 7:13 pm

Ecuadorian:
I had a look at your sample file. I see the issues. I think it's a tolerance issue. I'll have to investigate a little more to tune in the tolerance.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby Ecuadorian » Wed Oct 21, 2009 7:25 pm

Thanks! I think I now remember what the problem might be, also. The model is scaled a lot. :?
Ecuadorian
 
Posts: 1621
Joined: Thu Jan 15, 2009 10:20 pm
Location: Ecuador
Name: Miguel
Operating system: Windows
SketchUp version: 8
License type: Free
SketchUp use: architecture
Level of SketchUp: Intermediate

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 7:42 pm

This is strange. When I compare the dot product of various faces, I find an overlap in the return value for faces where you can erase the connecting edge:

Code: Select all
   # Not coplanar
   # 0.999999999898786
   # 0.999999999901467
   # 0.99999999992968
   # 0.99999999995352
   # 0.999999999959393
   # 0.999999999974808
   #
   # Coplanar
   # 0.999999999917881
   # 0.999999999918562
   # 0.999999999984962
   # 0.999999999999148
   # 0.999999999999408
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 7:42 pm

Ecuadorian wrote:Thanks! I think I now remember what the problem might be, also. The model is scaled a lot. :?

I did notice that - but I exploded it and it still occurs...
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby Chris Fullmer » Wed Oct 21, 2009 8:46 pm

Could you take the edge, find its connected faces. Then get the object id for those faces, and get all their vertices positions. Then delete the edge if it is planar. Then test to see if those faces still exist. If they do, move on. If they do not, then rebuild them using their vertices' positions? Painful yes, but maybe useful?

Chris
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer
SketchUp Team
 
Posts: 6690
Joined: Wed Nov 21, 2007 3:21 am
Location: Davis, CA
Name: Chris Fullmer
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: landscape architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 8:48 pm

Chris Fullmer wrote:Could you take the edge, find its connected faces. Then get the object id for those faces, and get all their vertices positions. Then delete the edge if it is planar. Then test to see if those faces still exist. If they do, move on. If they do not, then rebuild them using their vertices' positions? Painful yes, but maybe useful?

Chris

I did that kind of stuff in my previous version, prior to 7.1 - wasn't stable. So many cases to take into account. Faces with inner holes etc...
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 8:49 pm

I think I might have misunderstood this whole DOT product from vectors... will have to look deeper into it.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby Chris Fullmer » Wed Oct 21, 2009 8:49 pm

Can you hit ctrl-z in ruby? :)
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer
SketchUp Team
 
Posts: 6690
Joined: Wed Nov 21, 2007 3:21 am
Location: Davis, CA
Name: Chris Fullmer
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: landscape architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby remus » Wed Oct 21, 2009 8:57 pm

thomthom wrote:I think I might have misunderstood this whole DOT product from vectors... will have to look deeper into it.


What do you think is not working? from my quick browse of your script the dot product should do what you want.
remus
 
Posts: 8055
Joined: Fri Nov 30, 2007 8:48 am
Location: UK
Name: remus

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 8:58 pm

Chris Fullmer wrote:Can you hit ctrl-z in ruby? :)

Yea, http://code.google.com/intl/nb/apis/ske ... .html#undo
But that would ruin any kind of possibility to undo the whole erase coplanar operation.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 9:00 pm

...could create a temp group and use that to replicate the two faces (when within a range where we can't be certain.)

but I'd still try to avoid that if I can calculate this.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby honoluludesktop » Wed Oct 21, 2009 9:50 pm

Hi Thomas, I lost a texture from a face in a 61k faces model. BTW what happens when you have coplaner faces with different textures, or images placed on textured faces (say a run on a wood floor). Didn't read all the post, so sorry if already covered.
User avatar
honoluludesktop
In Remembrance
 
Posts: 2219
Joined: Fri Sep 12, 2008 12:08 am
Location: Hawaii

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 9:52 pm

honoluludesktop wrote:Hi Thomas, I lost a texture from a face in a 61k faces model. BTW what happens when you have coplaner faces with different textures, or images placed on textured faces (say a run on a wood floor).

At the moment it doesn't take into account materials. Only geometry.

Images? You mean an actual Image entity (It says "Image" in Entity Info when you select it?)
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby honoluludesktop » Wed Oct 21, 2009 9:55 pm

Well, I often import images (as images, not textures), and place them on textured faces.
Please, register (free) to access all the attachments on the forums.
Last edited by honoluludesktop on Wed Oct 21, 2009 10:00 pm, edited 1 time in total.
User avatar
honoluludesktop
In Remembrance
 
Posts: 2219
Joined: Fri Sep 12, 2008 12:08 am
Location: Hawaii

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Wed Oct 21, 2009 9:57 pm

honoluludesktop wrote:Well, I often import images (as images, not textures), and place them on textured faces.

They would be ignored.
However, I do plan on adding an option for it to respect the material of the geometry. Just got to sort out some other issue first.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby honoluludesktop » Wed Oct 21, 2009 10:01 pm

Opps, added image after your post.
User avatar
honoluludesktop
In Remembrance
 
Posts: 2219
Joined: Fri Sep 12, 2008 12:08 am
Location: Hawaii

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby Pilou » Thu Oct 22, 2009 3:00 am

Seems another very useful plug :enlight:
About the Ecuadorian file
Why not scale the file *10, apply the plug, then scale 1/10 ? ;)
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
Pilou
Top SketchUcator
 
Posts: 10048
Joined: Wed Jan 23, 2008 10:33 pm
Operating system: Windows
SketchUp version: 6
License type: Free
SketchUp use: hobby
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Thu Oct 22, 2009 7:01 am

Pilou wrote:Seems another very useful plug :enlight:
About the Ecuadorian file
Why not scale the file *10, apply the plug, then scale 1/10 ? ;)

The scale isn't the issue.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby chango70 » Thu Oct 22, 2009 12:29 pm

This works very well. I have made Ctrl Shift C short cut for it. Thank you!
chango70
 
Posts: 587
Joined: Tue Mar 25, 2008 3:06 pm
Location: London

Re: [Plugin] Cleanup (1.0.0) — 21 October 2009

Postby thomthom » Thu Oct 22, 2009 1:20 pm

Jim wrote:Ack! it doesn't look at materials?
Oh, and thank you! :thumb:

honoluludesktop wrote:Hi Thomas, I lost a texture from a face in a 61k faces model. BTW what happens when you have coplaner faces with different textures, or images placed on textured faces (say a run on a wood floor). Didn't read all the post, so sorry if already covered.

Option to respect materials applied added. On by default.

Ecuadorian:
I adjusted the tolerance so it shouldn't loose any geometry on the model you sent me. Hopefully it won't loose anything in other models either.
But there is some cases where which can be removed is left behind. I hope to address this. I figured it's best to be defensive than aggressive.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [Plugin] Cleanup (1.0.1) — 22 October 2009

Postby Ecuadorian » Thu Oct 22, 2009 1:24 pm

Sounds nice, Thom!
Perhaps you could give the user two or three threshold options.
Ecuadorian
 
Posts: 1621
Joined: Thu Jan 15, 2009 10:20 pm
Location: Ecuador
Name: Miguel
Operating system: Windows
SketchUp version: 8
License type: Free
SketchUp use: architecture
Level of SketchUp: Intermediate

Re: [Plugin] Cleanup (1.0.1) — 22 October 2009

Postby thomthom » Thu Oct 22, 2009 1:34 pm

Ecuadorian wrote:Sounds nice, Thom!
Perhaps you could give the user two or three threshold options.

I added an debug option which you can use for now. You can see it in the screenshot.
The closer to 1.0 the stricter it is.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17597
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Not a Premium Member yet? Check out the great time-limited deal we are offering.

Ad Machine
Robot
 
Posts: 2012

Next

Return to Plugins

Who is online

Users browsing this forum: Ahamd, Anton_S, Chris Fullmer, dmatho, Google Feedfetcher, jcabreraesc, JoshCham, lukasaurus, mitcorb, thanhnugent, thomthom and 8 guests