• Login
sketchucation logo sketchucation
  • Login
ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

How to modify texture color with code?

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 4 Posters 153 Views 4 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.
  • R Offline
    renderiza
    last edited by 26 Nov 2012, 10:28

    Hi,

    Is there a way to modify a texture color with code?

    Thanks

    [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 26 Nov 2012, 11:22

      Methods in https://developers.google.com/sketchup/docs/ourdoc/texture lets you find the material's texture's 'average_color' etc.
      Methods in https://developers.google.com/sketchup/docs/ourdoc/material lets you get/set a material's texture and also the material's color, opacity etc.

      TIG

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 26 Nov 2012, 12:42

        Note that the API is missing methods to make a texture Colorized.

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

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 26 Nov 2012, 13:00

          You can tell if a material is colorized, via https://developers.google.com/sketchup/docs/ourdoc/material#materialType which returns 2 if the material is 'textured and colorized' [or 0 is untextured and 1 if textured], but as TT says there is no effective way to change a material's 'colorization; settings in the API.

          The 'average_color' is useful for representing the material's texture as its RGB color when the view-mode isn't showing textures.

          TIG

          1 Reply Last reply Reply Quote 0
          • R Offline
            renderiza
            last edited by 26 Nov 2012, 20:53

            If I understood correctly it can't display the color changes while in texture mode. I hope one day the API will support such a task. Oh well I guess I need to use another method to achieve what I wanted which was to change the color of texturized clouds depending on the sun or moon is position.

            Thank you both

            [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

            1 Reply Last reply Reply Quote 0
            • A Offline
              Aerilius
              last edited by 26 Nov 2012, 21:41

              I think when setting a color to a textured material, the change becomes visible immediately, however the API does not differ between colorizing (checkbox in the materials browser) and color-shifting (pointer on the color wheel).

              Assuming you rotate the color wheel of a material A and get material B:
              colorize.png
              We can then read the color value of B:
              ` material.materialType

              2
              color = material.color
              Color(200, 147, 62, 255)then reset it to the texture image's original look: material.color = nil
              nilThis way we get A. material.materialType
              1then trying to set it again: material.color = color
              Color(200, 147, 62, 255)
              material.materialType
              2`
              This time it is also colorized (C) and we have no control about it.

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

              Advertisement