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

    [ruby] material colorize

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 1.2k Views 3 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.
    • K Offline
      kaas
      last edited by

      I'm testing a small tool to temporary turn all colors, for any material containing a texture, to white. Together with a shaded style this results in a black and white representation of the model.

      model = Sketchup.active_model
      materials = model.materials	
      
      materials.each {|m|
      	m.color = [255,255,255,255]
      }
      

      Annoying thing is: if you run the code, SketchUp is checking the 'colorize' flag (see pic) for the materials which can't be unchecked with code when reverting back to the original settings.

      Already found some topics about this behavior:
      http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=49184%26amp;p=442077%26amp;hilit=colorize#p442077
      http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=22488%26amp;p=189349%26amp;hilit=colorize#p189349

      The topics are rather old - any new ways to prevent this OR to uncheck the colorize flag by code?


      colorize.jpg

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        As of SU2015 you can get and set the colorize properties: http://www.sketchup.com/intl/en/developer/docs/ourdoc/material

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • K Offline
          kaas
          last edited by

          Thanks, I already used that method for reverting to the original settings.

          Had another look...turns out I just have to add 'm.colorize_type= 0' when setting everything to white to prevent SketchUp to automatically use the colorize option.

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by

            do you really need to tamper with textures?
            I just use rendering options to output a series of different styles...

            bit like this...

            @start =  []
            @start << Sketchup.active_model.rendering_options["FaceFrontColor"] # templates default
            @start << Sketchup.active_model.rendering_options["RenderMode"]  # templates default
            
            def change_color
              Sketchup.active_model.rendering_options["FaceFrontColor"] = 'white' #  or use
             # (Sketchup;;Color.new(255,255,255,255))
              Sketchup.active_model.rendering_options["RenderMode"] = 5 #monochrome
            end
            
            def revert_color
             Sketchup.active_model.rendering_options["FaceFrontColor"] = @start[0]
             Sketchup.active_model.rendering_options["RenderMode"] = @start[1]
            end
            

            john

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

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Oh - good point. Are you making everything 100% white? I thought at first you wanted to desaturate and lighten the textures.
              But if you only going to make everything white then rendering options is the way to go - no messing with the undo stack etc.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • K Offline
                kaas
                last edited by

                I use the tool to quickly switch two modes: textured / colored AND grey scale

                I have a fully textured 3d model and a sectioncut with faces in several shades of grey. In layout I need a grey scale representation without textures. The grey scale colors of the section cut must be preserved.

                So the tool temporary converts the colors to grey scale, makes the material color for those materials with a texture to white and sets the style to shaded.

                Previously I needed two scenes in SU and one extra layer in LO to achieve the same result in LO.


                switch.jpg

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

                Advertisement