by TIG » Thu Aug 04, 2011 3:34 pm
Copy=paste code into a file called colorthinfaces.rb in the Plugins folder, save and restart Sketchup - Code: Select all
### (c) TIG 2011 ### Usage: Type in Ruby Console ### TIG.colorthinfaces ### Any faces 'thinner' < 3mm are marked colored 'Magenta' ### or 'Cyan' on back to help see reversed too. ### To check for other dimensions add an number as an argument, e.g. ### TIG.colorthinfaces 10.1 ### to mark faces < 10.1 current units e.g. 10.1mm, 10.1cm, 10.1" etc. ### To specify units other than 'current units' add a suffix [with '.'] ### TIG.colorthinfaces 4.mm ### to marks all faces < 4mm, irrespective of the current unit settings. ### It's one step undo-able. ### v1.1 20110804 Angle faces glitch trapped. ### v1.2 20110804 Now marks ALL faces in model and definitions ### and marks faces with thin parts even if bounds are larger, ### back-faces become Cyan to help check reversed faces too. module TIG def self.colorthinfaces(t=3.0.mm) t=t.to_s.to_l t=t-0.1.mm ### i.e. ensure 3mm is OK model=Sketchup.active_model faces=[] model.entities.each{|e|faces<<e if e.class==Sketchup::Face} model.definitions.each{|d| next if d.image? d.entities.each{|e|faces<<e if e.class==Sketchup::Face} } nfaces=[] faces.each{|e| thin=false e.edges.each{|ed| sp=ed.start.position ve=ed.line[1] mp=sp.offset(ve,ed.length/2) tr=Geom::Transformation.rotation(sp,e.normal,90.degrees) ve.transform!(tr) pt1=mp.offset(ve,t) pt2=mp.offset(ve.reverse,t) if e.classify_point(pt1)!=Sketchup::Face::PointInside and e.classify_point(pt2)!=Sketchup::Face::PointInside thin=true break end } nfaces << e if thin } nfaces.uniq! model.start_operation('colorthinfaces') nfaces.each{|e| e.material='Magenta' e.back_material='Cyan' } model.commit_operation end end
TIG
-

TIG
- Global Moderator
-
- Posts: 13992
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by driven » Thu Aug 04, 2011 4:15 pm
hi Tig,
I don't get anything happening on the mac...
saved and installed properly, nothing on test file, so I restarted SU and created 1mm thick cuboid, made it a group, made it a component, only default materials showing in model?
this a mac issue?
and if I enter it in Ruby Console it returns nil, and still nothing happens... john
-
driven
- Top SketchUcator
-
- Posts: 1409
- Joined: Fri May 01, 2009 11:50 pm
- Name: John
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by TIG » Thu Aug 04, 2011 4:20 pm
No! it needs 'raw faces' in the active_entities context - so edit the group and run it... It doesn't [yet] mine down into definition's faces... Incidentally there's a new version in the first post...
TIG
-

TIG
- Global Moderator
-
- Posts: 13992
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by TIG » Thu Aug 04, 2011 5:03 pm
Here's v1.2 viewtopic.php?p=346362#p346362It now marks all thin faces Magenta, even if they are part of a face that is larger than the size limit otherwise. It will mark 'needle' shaped faces [or larger faces with 'spikes'] provided that the average thickness of the tapering part of the face is below the size limit; i.e. it will not mark it if it is fatter than the size limit at its center. It colors the backs of thin faces Cyan so you can spot if they are thin AND reversed!
TIG
-

TIG
- Global Moderator
-
- Posts: 13992
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by driven » Thu Aug 04, 2011 5:43 pm
colourfaces.png is this as you'd expect? seems to be functioning on mac cheers john
Please, register (free) to access all the attachments on the forums.
-
driven
- Top SketchUcator
-
- Posts: 1409
- Joined: Fri May 01, 2009 11:50 pm
- Name: John
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by TIG » Thu Aug 04, 2011 6:16 pm
Except for that larger magenta face on the left ? Perhaps it has a thin projection we can't see in this view ??  You also have a lot of thin faces [Cyan] that need reversing. I suggest you view in Monochrome mode to see these [and thicker faces looking 'bluish'] and reverse them all... because the 'white' should show outwards in a 'solid' - especially for 3d printing or even rendering on most apps...
TIG
-

TIG
- Global Moderator
-
- Posts: 13992
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by driven » Thu Aug 04, 2011 6:39 pm
hi Tig,
I should have left the section plane showing, the cyan is all inside, and all the faces are orientated correctly, I used the skp from the other thread because it was there, and although solid, it does need a good cleanup,
I'll test on one of my own later on... john
-
driven
- Top SketchUcator
-
- Posts: 1409
- Joined: Fri May 01, 2009 11:50 pm
- Name: John
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by TIG » Thu Aug 04, 2011 7:59 pm
No probs... Feedback is welcome...............
TIG
-

TIG
- Global Moderator
-
- Posts: 13992
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by kyyu » Fri Aug 05, 2011 1:54 am
Hi Tig, Works fine in simple cases, but missed some faces in this crossed pattern. colorthinfaces_1.png
Please, register (free) to access all the attachments on the forums.
-
kyyu
-
- Posts: 150
- Joined: Mon Jan 25, 2010 12:32 pm
- Location: Maryland, USA
- Name: Kwok Yu
by TIG » Fri Aug 05, 2011 9:15 am
Kyyu
Strange it should look at each face the same way... Can you supply that SKP so I can test it ? How thin are the faces? 2.95mm might creep in ?
TIG
-

TIG
- Global Moderator
-
- Posts: 13992
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by kyyu » Fri Aug 05, 2011 12:32 pm
TIG wrote:Kyyu
Strange it should look at each face the same way... Can you supply that SKP so I can test it ? How thin are the faces? 2.95mm might creep in ?
TIG, I didn't save the original one, but I made up another one. The width was 2mm. Got similar result. colorthinfaces_crossed faces example.skp
Please, register (free) to access all the attachments on the forums.
-
kyyu
-
- Posts: 150
- Joined: Mon Jan 25, 2010 12:32 pm
- Location: Maryland, USA
- Name: Kwok Yu
by TIG » Fri Aug 05, 2011 12:57 pm
Capture.PNG Worked fine for me [eventually] BUT you have several 'overlaid' coplanar/coincident faces - which is a known but weird phenomenon sometimes found with small faces etc. To fix it 'select all', and 'intersect with selection' - the duplicate faces disappeared and the cyan colored faces are shown.
Please, register (free) to access all the attachments on the forums. TIG
-

TIG
- Global Moderator
-
- Posts: 13992
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by Rich O Brien » Fri Aug 05, 2011 1:24 pm
To fix it 'select all', and 'intersect with selection'
Is that how to fix that nuisance of faces on faces on faces etc? I never knew that 
-

Rich O Brien
- Administrator
-
- Posts: 8301
- Joined: Fri Oct 31, 2008 9:05 am
- Location: Limerick, Ireland
- Name: Rich O'Brien
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Advanced
Return to Plugins
|