[Plugin] colorthinfaces v1.2 20110804

[Plugin] colorthinfaces v1.2 20110804

Postby 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
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] colorthinfaces 20110804

Postby 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
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] colorthinfaces 20110804

Postby 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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby TIG » Thu Aug 04, 2011 5:03 pm

Here's v1.2 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!
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby driven » Thu Aug 04, 2011 5:43 pm

colourfaces.png

is this as you'd expect?

seems to be functioning on mac

cheers
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby 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...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby 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
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby TIG » Thu Aug 04, 2011 7:59 pm

No probs... ;)
Feedback is welcome...............
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby 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
0

kyyu 
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby 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 ?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby 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
0

kyyu 
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby 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.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] colorthinfaces v1.2 20110804

Postby 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 :thumb:
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: Google Bot, ZElena and 14 guests

Visit our sponsors: