@tig said:
Hope I'm not standing on any toes...
### edited/replace the code from here................
> faces = []
> flat = []
> angle = 0.0
> sel.each do |e|
> faces << e if e.is_a? Sketchup;;Face
> end#do
> ### first set up some [r,g,b] colors for various slope angles
> ### we use them if they exist, but if not make them...
> if not color_00_20 = model.materials["color_00_20"]
> color_00_20 = model.materials.add("color_00_20")
> color_00_20.color= [120,0,0]
> end#if
> if not color_20_40 = model.materials["color_20_40"]
> color_20_40 = model.materials.add("color_20_40")
> color_20_40.color= [150,0,0]
> end#if
> if not color_40_60 = model.materials["color_40_60"]
> color_40_60 = model.materials.add("color_40_60")
> color_40_60.color= [180,0,0]
> end#if
> if not color_60_80 = model.materials["color_60_80"]
> color_60_80 = model.materials.add("color_60_80")
> color_60_80.color= [210,0,0]
> end#if
> if not color_80_90 = model.materials["color_80_90"]
> color_80_90 = model.materials.add("color_80_00")
> color_80_90.color= [240,0,0]
> end#if
> ### you can adjust the colors' rgb values to suit...
> ###
> faces.each do |e|
> enorm = e.normal
> flat = Geom;;Vector3d.new(enorm[0],enorm[1],0)
> angle = (flat.angle_between enorm).radians ### angle in in degrees
> ### now set up the tests for different angles
> ### change these test ranges etc to suit your requirements...
> if angle>=0.0 and angle<=20.0
> color=color_00_20
> elsif angle>20.0 and angle<=40.0
> color=color_30_40
> elsif angle>40.0 and angle<=60.0
> color=color_40_60
> elsif angle>60.0 and angle<=80.0
> color=color_60_80
> else ### angle>80.0
> color=color_80_90
> end#if
> e.material = color
> e.back_material = color
> end#do
> ### end of edit/replace.................
>
Make a backup copy of the original ruby script outside of the Plugins folder so it won't try load twice. If you mess up then you have the original to use again...
Now edit/replace the version that's still in the Plugins folder, as set out above [open with Notepad.exe or equivalent plain-text editor].
Save it and restart Sketchup - all slopes should now be colored in the angle-ranges and colors you've specified...
Hello,
Can you please explain how to do it 'step by step'? I've never used ruby script, however this tool will be very usefull for me if I can influence the slope colours.
Thank you for your help:)