[Plugin] colorthinfaces v1.2 20110804
-
Copy=paste code into a file called
colorthinfaces.rb
in the Plugins folder, save and restart Sketchup### (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
-
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 -
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... -
Here's v1.2 http://forums.sketchucation.com/viewtopic.php?p=346362#p346362
It 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! -
is this as you'd expect?seems to be functioning on mac
cheers
john -
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... -
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 -
No probs...
Feedback is welcome............... -
Hi Tig,
Works fine in simple cases, but missed some faces in this crossed pattern.
-
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 said:
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.
-
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. -
@unknownuser said:
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
Advertisement