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

    This method of apply color working?

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 3 Posters 429 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.
    • thomthomT Offline
      thomthom
      last edited by

      Works for me...

      Sketchup.active_model.selection[0].material = "#ff0000"

      What happens for you?

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

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Works fine for me too...
        Perhaps your reference ' face' is invalid ?

        TIG

        1 Reply Last reply Reply Quote 0
        • renderizaR Offline
          renderiza
          last edited by

          Hi, here is an example of what I a did...

          model = Sketchup.active_model
          ents = model.active_entities
          faces = ents.grep(Sketchup;;Face)
          materials = model.materials
          m = materials.add "shadow"
            
          faces.each do |e|
          
              e.material = [255, 0, 0] # <--This Works
            
              e.material = "#ff0000" # <--This Do Not
           
          end
          

          You can see full code on here...http://sketchucation.com/forums/viewtopic.php?f=323&t=52871

          Since I had the input result come in hex mode thru web-dialog what I did to make it work on Ruby was to first change it into RGB in Javascript. πŸ˜•

          Cheers!

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

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

            What happens when it "doesn't work"? Error messages?

            Your snippet works for me...

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

            1 Reply Last reply Reply Quote 0
            • renderizaR Offline
              renderiza
              last edited by

              Interesting...

              Doesn't work on SU 8 but works on SU 2013.

              Is that suppose to happen?

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

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

                Probably a new feature then.

                Which explain why I couldn't remember seeing that way of assigning material. (Which I'd written about in my blog: http://www.thomthom.net/thoughts/2012/03/the-secrets-of-sketchups-materials/#hexadecimal-notation )

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

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

                  Seems to be a new feature of the Sketchup::Color class.

                  ` Sketchup::Color.new '#ff0000'
                  Color(255, 0, 0, 255)

                  Sketchup::Color.new '#f00'
                  Color(255, 0, 0, 255)`

                  Works in SU2013 - but not SU8. And Not documented in the docs when it was implemented.

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

                  1 Reply Last reply Reply Quote 0
                  • renderizaR Offline
                    renderiza
                    last edited by

                    I see that explains everything. πŸ‘

                    It is very good that SketchUp API is being updated...hope to see more changes in the future.

                    cheers!

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

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

                      Yea - I've noticed some changes here and there recently.

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

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        It has been shown in the API for years, but I think it was broken until v2013...

                        TIG

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

                          0x0000FF has always worked. Was it not that that was displayed?

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

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

                            ah... I just checked the Way Back Machine... it was there before SU2013.

                            Link Preview Image
                            SketchUp Ruby API

                            favicon

                            (web.archive.org)

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

                            1 Reply Last reply Reply Quote 0
                            • TIGT Offline
                              TIG Moderator
                              last edited by

                              That was and is displayed.
                              But it think the string equivalent was always shown but just didn't work until now πŸ˜•

                              TIG

                              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