by Agama » Mon Mar 21, 2011 8:14 pm
TIG wrote:Hope I'm not standing on any toes... - Code: Select all
### 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:)
-
Agama
-
- Posts: 1
- Joined: Wed Mar 16, 2011 6:28 pm
by dansphere » Wed Nov 02, 2011 9:30 pm
Yes I'm also having trouble, I've had a shot at changing the ruby but no luck. Perhaps a logarithmic function for the assignment of colour to slope angle would work well, and then being able to reverse the log direction.. ??
Dan
-
dansphere
-
- Posts: 6
- Joined: Tue Mar 16, 2010 3:24 am
- Location: Wales
- Name: daniel bates
- Operating system: Mac
- SketchUp version: 2013
- License type: Free/Make
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Chris Fullmer » Thu Nov 03, 2011 8:23 pm
What are you trying to do Dan? Just use a different method of determining the color to assign?
-

Chris Fullmer
- SketchUp Team

-
- Posts: 6929
- Joined: Wed Nov 21, 2007 3:21 am
- Location: Boulder, CO
- Name: Chris Fullmer
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by brookefox » Tue Mar 20, 2012 7:55 pm
Here we have a near flat creek be with sloping sides and a near flat upper terrain. Faces picked to be colored are still shown picked. Highest slope r255 g0 b0; lowest r0 g0 b255 (or something like these values). There are some blue vertical slopes elsewhere. I think it would be helpful if the flats got colored, too. So everything gets a color value. I would have thought lowest slope = flat, rather than vertical, which it seems to be. color by slope-2.JPG I had wanted to try to use this as a means of selecting the slopes vs. the near flats for grouping, which I did manually with not too much difficulty.
~ Brooke
-

brookefox
-
- Posts: 826
- Joined: Thu Jun 26, 2008 4:17 pm
- Location: Pacific northwest, USA
- Name: Brooke
- Operating system: Windows
- SketchUp version: 8
- License type: Free/Make
- SketchUp use: architecture
- Level of SketchUp: Intermediate
by sherwood11 » Fri Aug 17, 2012 4:42 pm
Hello, The plug-in appears to load properly. However, I get this Ruby Console feedback when I run it.
segment 3 [60 to 90] segment 2 [30 to 60] segment 1 [0 to 30] Error: #<ArgumentError: comparison of Float with nil failed> (eval):2304:in `>' (eval):2304:in `update' C:/Program Files/Google/Google SketchUp 8/Plugins/clf_color_by_slope.rb:230:in `colorbyslope' C:/Program Files/Google/Google SketchUp 8/Plugins/clf_color_by_slope.rb:223:in `each' C:/Program Files/Google/Google SketchUp 8/Plugins/clf_color_by_slope.rb:223:in `colorbyslope' C:/Program Files/Google/Google SketchUp 8/Plugins/clf_color_by_slope.rb:254 (eval):2304:in `call' (eval):2304
Has anyone encountered this before ? .... any solution or direction to resolve ? I have checked that faces are faces (not surfaces). Segment materials appear in the list of materials. The faces just don't want to color ...
Thank you for your help
-
sherwood11
-
- Posts: 23
- Joined: Sat Jul 14, 2012 11:50 pm
- Location: california
- Name: sherwood11
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by sdmitch » Fri Aug 17, 2012 7:04 pm
The problem appears to be associated with the progress bar. C:/Program Files/Google/Google SketchUp 8/Plugins/clf_color_by_slope.rb:230:in `colorbyslope'
refers to the the statement pb.update(count)
If the problem persists, then I would just comment or remove the line. The only consequence will be progressbar will never update but, unless the model is huge, you will not know the difference.
-

sdmitch
- PluginStore Author

-
- Posts: 1496
- Joined: Wed Mar 02, 2011 9:21 pm
- Name: sdmitch
- Operating system: Windows
- SketchUp version: 2014
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by sherwood11 » Fri Aug 17, 2012 7:53 pm
Yeess, Thank You ! I commented out that line ... - Code: Select all
#pb.update(count)
I was/am testing it on a very small dummy file. I shall investigate my version(copy) of progressbar.rb Thanks again
-
sherwood11
-
- Posts: 23
- Joined: Sat Jul 14, 2012 11:50 pm
- Location: california
- Name: sherwood11
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by sherwood11 » Fri Aug 17, 2012 8:34 pm
sd,
Based on your help, I also found that my version of progressbar.rb was affecting :
clf_color_by_z.rb clf_greeble_2.rb
So, it turns out to be predictable....
Thanks again
-
sherwood11
-
- Posts: 23
- Joined: Sat Jul 14, 2012 11:50 pm
- Location: california
- Name: sherwood11
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by TIG » Fri Aug 17, 2012 8:39 pm
Do you have the current version of ' progressbar.rb' - which can be downloaded free from http://Smustard.com ?
TIG
-

TIG
- Global Moderator
-
- Posts: 20265
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by sherwood11 » Fri Aug 17, 2012 9:54 pm
TIG, .. I just downloaded and compared both files. They appear to be identical ... Author, date, history, no. of lines, size, etc. (by-the-way, it is in the 'plugins\' folder) However, I still replaced it with the fresh download. I did a search and found another progressbar.rb in another folder ... plugins\TT_Lib2\ They are different, but I can't see how it would have an affect... I temporarily renamed it. I un-commented the pb.update(count) lines in the clf_... .rb files and I still received the same Ruby Console feedback, as before. posting.php?mode=reply&f=323&t=20635#I restored things back to working order and will continue to debug another day. I appreciate your suggestion, Thanks much I'll post when(if) I find the solution.
-
sherwood11
-
- Posts: 23
- Joined: Sat Jul 14, 2012 11:50 pm
- Location: california
- Name: sherwood11
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by TIG » Fri Aug 17, 2012 10:09 pm
When an author includes a file inside their own subfolder like TT's it's to keep a similar but separate code set. Don't worry about that one. Are you sure the require files are all really inside Plugins and not sidetracked by some 'Compatibility Files' OS trickery because you don't have FULL access rights to the Plugins folder ???
TIG
-

TIG
- Global Moderator
-
- Posts: 20265
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by sherwood11 » Fri Aug 17, 2012 10:58 pm
Ahh ... require files ... sketchup.rb is in ...google sketchup8\tools\ progressbar.rb is in ...google sketchup8\plugins\ offset.rb is in ...google sketchup8\plugins\ (additional require file in greeble_2.rb) I have administrative access to my computer.. is that what you mean ? I see all file extensions...ie, hidden etc. i keep my program files rooted under c:\ majority of other files under user\username\documents .. user\username\downloads, etc. I noticed this (if it matters): single quotes in color_by_slope and color_by_Z require 'sketchup.rb' require 'progressbar.rb' double quotes in greeble_2.rb require "sketchup.rb" require "offset.rb" require "progressbar.rb" I here ya about the 'Compatibility Files' OS trickery stuff ... frustrating at times. in a few hours I'll do a complete fulll search to try and get to the bottom of this. or maybe it could just be my computer ... it does wonky things on occasion and it's about 100 degree (F) outside here today ... 
-
sherwood11
-
- Posts: 23
- Joined: Sat Jul 14, 2012 11:50 pm
- Location: california
- Name: sherwood11
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by TIG » Sat Aug 18, 2012 9:04 am
Don't worry about 'xxx' and "xxx" these enclose a text string xxx - and they are often synonymous. Although 'escaped' characters [\n etc] behave differently inside them.
A require statement is simply a way of ensuring that a file is loaded before the rest of the code. If it has already been loaded [for example by a script that loaded earlier] then it's skipped over this time. Some special functions are created by the sketchup.rb so it's often 'required' in scripts, the progressbar.rb adds a visual progressbar in the status text to show you how far along the processing has got. You don't need to worry about a required file's location. Sketchup's own files [like Sketchup.rb] are kept in the Tools folder. The vast majority of others go into Plugins folder, as directed by each tools installation notes... As Ruby files are auto-loaded as Sketchup starts a system array is read - $LOAD_PATH - by default this includes the path to the Plugins folder and then Tools folder - so 3rd party tools add extra paths to it at startup so that Sketchup loads files from additional locations as well. Files load in alphanumeric order so 'aaa.rb' loads before 'xxx.rb' from Plugins. Because 'sketchup.rb' loads later on from the Tools folder it's important that scripts loading from Plugins 'require' it so it's preloaded to be used by their code. Some rogue/misguided scripts add an old 'Sketchup.rb' file into Plugins. If so then please remove it; the only copy should be the one installed by Sketchup itself, and that must be in Tools. 'Compatibility Files' can cause unexpected issues - ensure your security permissions to all files an subfolders within the Sketchup folder are set to 'FULL'. This is particularly important for the correct installation of scripts and their subfolders of helper files inside Plugins, and also not frgeting the Materials, Components and Styles folders, where you may wish to use 'save_as' for some aspects of your models, or to keep 'libraries' of others bits...
TIG
-

TIG
- Global Moderator
-
- Posts: 20265
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by sketchy » Wed Oct 30, 2013 8:51 pm
does this script work for 2013? I tried downloading from the extension warehouse and got some odd error messages. Next I tried the smustard download and installed in the plugin folder (along with progress bar plugin), restarted sketchup, checked my plugin section and do not see it any where. Am I missing something? I would love to try this out. thanks for any help you can shed
-
sketchy
-
- Posts: 217
- Joined: Wed Nov 28, 2007 8:32 pm
- Location: New Mexico
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by Dave R » Wed Oct 30, 2013 9:15 pm
What were the "odd error messages"?
Etaoin Shrdlu
%
(THERE'S NO PLACE LIKE)
G28 X0.0 Y0.0 Z0.0
M30
%
-

Dave R
- Global Moderator
-
- Posts: 18141
- Joined: Tue Nov 13, 2007 11:52 pm
- Location: SE Minnesota
- Name: Dave R
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: woodworking
- Level of SketchUp: Advanced
by sketchy » Wed Oct 30, 2013 9:23 pm
I tried it again to get the direct quote and this time it worked. It may be that I tried the extension warehouse first then smustard. When looking at the smustard site it listed the prerequisite ruby (progress bar) which I installed.
If this were true it would raise the question: does the extension warehouse (via SU) give a warning or list of prerequisite scripts?
-
sketchy
-
- Posts: 217
- Joined: Wed Nov 28, 2007 8:32 pm
- Location: New Mexico
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by Dave R » Wed Oct 30, 2013 9:28 pm
Requires progressbar.rb probably ought to be included on the Extension Warehouse page. It should be indicated in the first post of the original thread here on SCF. The error message you got most likely would have indicated that progressbar.rb was missing as well.
Etaoin Shrdlu
%
(THERE'S NO PLACE LIKE)
G28 X0.0 Y0.0 Z0.0
M30
%
-

Dave R
- Global Moderator
-
- Posts: 18141
- Joined: Tue Nov 13, 2007 11:52 pm
- Location: SE Minnesota
- Name: Dave R
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: woodworking
- Level of SketchUp: Advanced
by sketchy » Wed Oct 30, 2013 9:33 pm
Thanks for the quick help, its working now and great for what I am doing
-
sketchy
-
- Posts: 217
- Joined: Wed Nov 28, 2007 8:32 pm
- Location: New Mexico
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by Chris Fullmer » Wed Oct 30, 2013 10:38 pm
Weird, I'll try to test the version on the warehouse. The one on the EW should not need progressbar though. I removed that dependency from that version. But maybe I introduced a bug in the process 
-

Chris Fullmer
- SketchUp Team

-
- Posts: 6929
- Joined: Wed Nov 21, 2007 3:21 am
- Location: Boulder, CO
- Name: Chris Fullmer
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by sergos » Mon Dec 09, 2013 3:48 pm
Chris Fullmer wrote:Weird, I'll try to test the version on the warehouse. The one on the EW should not need progressbar though. I removed that dependency from that version. But maybe I introduced a bug in the process 
Hello Chris! How it possible to do, what plug in coloring face by slope range? For example 0-10 red; 10-20 orange; 20-30 yellow............... I really need this function to analyses terrain by slope. Thanks
-
sergos
-
- Posts: 1
- Joined: Mon Jan 28, 2013 10:07 am
- Name: Sergio
by pilou » Mon Dec 09, 2013 4:21 pm
Maybe "Color By" by Sdmitch? (not retested) 
-

pilou
- Top SketchUcator
-
- Posts: 21105
- Joined: Wed Jan 23, 2008 10:33 pm
- Name: Pilou
- Operating system: Windows
- SketchUp version: 2017
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Advanced
-
by tpl » Mon Mar 09, 2015 6:02 pm
Hello Tig (and Chris), Thank you to you both for the original colr by slope ruby and the modifications to it to show colors for various slope angles. I have found the rz. file but it is unclear what needs to be edited and replaced. Is a new color by slope plug in for the various angles available? Thanks again, TP Light - Now CA (previously UK) TIG wrote:Hope I'm not standing on any toes... - Code: Select all
### 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... 
-
tpl
-
- Posts: 1
- Joined: Sat Feb 02, 2008 5:57 am
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Plugins
|