• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

[Plugin] Color by Slope

Scheduled Pinned Locked Moved Plugins
52 Posts 25 Posters 57.5k Views 25 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    icepam
    last edited by 17 Jul 2009, 21:33

    @mike lucey said:

    Thanks Chris, I wonder what it could be used for, other than visual effects? Has anyone any ideas .... I probably end up saying Doh!

    It is an amazing utility if you work with landscape and terrains. I'm an urban designer and architect and I use it for example to figure out which parts of a terrain are too steep to build on etc.

    geologists use slope analysis to figure out if there is any danger of landslides, and landscape designers to figure out what they can plant where.

    you can also use it to figure out if snowfall will build on certain areas and not others.

    and from a "image creation" perspective, if you combine the color by slope and the color by z, you could "automatically" create procedural maps of materials for example if you have a mountain, you can cover the highest parts with snow, the flat parts with grass, and the sheer parts with rock πŸ˜„

    1 Reply Last reply Reply Quote 0
    • M Offline
      Mike Lucey
      last edited by 17 Jul 2009, 23:52

      Thanks Icepam for that informitive description, and yes I agree that Colour by Slope would be invaluable in these cases.

      Support us so we can support you! Upgrade to Premium Membership!

      1 Reply Last reply Reply Quote 0
      • J Offline
        JClements
        last edited by 18 Jul 2009, 16:38

        Mike:

        For freeform shapes, I can see where it could be used as a contrasting tool (like bumping up the contrast in your photoediting software) where SU's builtin Sun for Shading doesn't quite do the trick.

        I am wondering if you could start with a grayscale mapping of the surface slopes, then take the grayscale value for each surface and tweek the HLS value of colors used for the surface, create a Palette of these shades, and apply them to their respective surfaces.

        John | Illustrator | Beaverton, Oregon

        1 Reply Last reply Reply Quote 0
        • D Offline
          Didier Bur
          last edited by 18 Jul 2009, 23:32

          Hi,

          @unknownuser said:

          you could start with a grayscale mapping of the surface slopes, then take the grayscale value for each surface and tweek the HLS value of colors used for the surface, create a Palette of these shades, and apply them to their respective surfaces

          I've done something similar (well, sort of) in my "paint_altitude_faces.rb" veeeeery ooooold script. Go look into it if it can help, it is not crypted πŸ˜‰

          DB

          1 Reply Last reply Reply Quote 0
          • M Offline
            mattg
            last edited by 19 Aug 2009, 12:13

            Chris,

            Was just wondering if you updated your version of the script with all the new inclusions? No offense intended, but im not sure how stable or whatever the other versions are.

            Cheers.

            -Matt

            1 Reply Last reply Reply Quote 0
            • O Offline
              olishea
              last edited by 19 Aug 2009, 16:09

              thanks for this plugin. im a big fan of your color by z plugin too, I use it far too often!

              oli

              1 Reply Last reply Reply Quote 0
              • C Offline
                Chris Fullmer
                last edited by 1 Sept 2009, 01:20

                UPDATE! version 1.5 available. (But not much changed, just compiled all the scripts that had been lying around this thread, and now I've uploaded it to smustard to host).

                @MattG, sorry it took so long to respond here! Yes, the other versions that were posted were quite stable. I've now consolidated everything into a single script and uploaded it to smustard.com:

                @Olishea - thanks! I'm glad you like these scripts πŸ˜„ It always nice to know poeple use some of them.

                Download
                http://www.smustard.com/script/ColorBySlope

                So go there now to download the final version of this script (I made one or two minor tweaks that might improve the speed, but I wouldn't count on it).

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

                1 Reply Last reply Reply Quote 0
                • M Offline
                  mattg
                  last edited by 1 Sept 2009, 11:44

                  Nah no worries.
                  Thankyou so much for this and all you other scripts - you're an absolute legend!

                  1 Reply Last reply Reply Quote 0
                  • E Offline
                    Ecuadorian
                    last edited by 17 Sept 2009, 20:46

                    Thank you, Chris!

                    I could have used this when I was a student, as I had to do it manually for Urban Design class. You know, to decide which parts of a site to use for housing, which ones for parks, which ones not to use at all, etc.

                    -Miguel Lescano
                    Subscribe to my house plans YouTube channel! (30K+ subs)

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      riboflavele
                      last edited by 20 Apr 2010, 19:03

                      I im trying to use this script, but i want to know its possible to change the colors and is it possible to know the slope % vs colors...? im not sure if my question is clear... Is it possible to have a legend or somthing to see for example that blue = 0% to 20% of slope and red = 40% to 60% of slope...

                      Sorry for my english...

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by 20 Apr 2010, 20:20

                        See
                        mat.color=[(255-value),value,value]
                        line #56~
                        Sets the face color, value is set by the angle...
                        Edit it there...
                        ❓

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          halsktchup
                          last edited by 27 Jun 2010, 18:38

                          TIG, Chris,

                          Thanks for the color by slope script. Like another person in here, I too am trying to see if I can get specific colors for specific slopes. Is there a later version to your script on smustard that contains this? For example if I need a certain red for anything above 20% slope, how do I get that?

                          Thanks.

                          1 Reply Last reply Reply Quote 0
                          • C Offline
                            Chris Fullmer
                            last edited by 27 Jun 2010, 22:33

                            Hey, so far the script does not do that. I do plan on implementing it eventually. I've got a super busy week and I do not anticipate being able to look at it right away, but it might be easy enough to just tweak some lines of code to make it work how you want. Maybe by next weekend I'll be able to look at it.

                            Chris

                            Lately you've been tan, suspicious for the winter.
                            All my Plugins I've written

                            1 Reply Last reply Reply Quote 0
                            • TIGT Offline
                              TIG Moderator
                              last edited by 28 Jun 2010, 08:32

                              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...
                              πŸ€“

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • C Offline
                                Chris Fullmer
                                last edited by 28 Jun 2010, 16:49

                                @tig said:

                                Hope I'm not standing on any toes... πŸ˜•

                                Nope, not at all! Thanks TIG,

                                Chris

                                Lately you've been tan, suspicious for the winter.
                                All my Plugins I've written

                                1 Reply Last reply Reply Quote 0
                                • A Offline
                                  anilnimesh
                                  last edited by 3 Nov 2010, 13:53

                                  Color by angle by you is amazing...
                                  πŸ˜‰ rather i had changed name of the tool as 'Slope by angle' πŸ˜„

                                  wow! ur work is amazing.

                                  Please brief about color assignments in case of 'color by Slope'?

                                  About myself, i m an Architect from India and doing practice in Delhi.
                                  regards,
                                  Anil Nimesh

                                  1 Reply Last reply Reply Quote 0
                                  • C Offline
                                    Chris Fullmer
                                    last edited by 3 Nov 2010, 15:37

                                    @anilnimesh said:

                                    Please brief about color assignments in case of 'color by Slope'?

                                    Thanks for using my plugin. I'm not entirely sure what you are requesting though. Let me know if there is a feature you think should be added, thanks!

                                    Chris

                                    Lately you've been tan, suspicious for the winter.
                                    All my Plugins I've written

                                    1 Reply Last reply Reply Quote 0
                                    • A Offline
                                      anilnimesh
                                      last edited by 3 Nov 2010, 16:00

                                      Hi Chris,
                                      i using sketchu pro v7.
                                      while using the tool, it is bit difficult to understand, which color is applied for which slope. i need to calculate, hw the tool is working?
                                      is there any color which defines slope (like 0-5% or 5%-10%) in slabs? i mean say 'red' for slope slab 0-5%

                                      u wrote highest color no. is for low gradient and vice versa. u also wrote to explode the group (containing the terrain) and select color and make a new group out of those.

                                      i tried but found it little tidious... πŸ˜†

                                      althought it is much simplied then what we do manually.. πŸ˜„ but i need to understand more about your tool.

                                      u also made a new one for v8 where it is called 'Color by slope stepped'. i found the previous one more relevant for my work.

                                      so i need to know that can the tool defines colors w.r.t. slope in slabs (like 0-5% or 5%-10%) ?

                                      regrds,

                                      1 Reply Last reply Reply Quote 0
                                      • A Offline
                                        Agama
                                        last edited by 21 Mar 2011, 19:14

                                        @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:)

                                        1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          dansphere
                                          last edited by 2 Nov 2011, 20:30

                                          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

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 2 / 3
                                          • First post
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement