sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Can I "store" a material as object in a variable?

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

      @jim said:

      You could do that, but there is also no way to load the .skm file from Ruby.

      😲

      doh! 😠

      Ok - in that case: export the texture bitmap and base64 encode/decode that. Which means you have to do extra work to extract the rest of the data for the Material and Texture objects.

      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

        With IE8 being able to use data URIs (although limited to 32k) it was very tempting to send texture data directly to webdialogs. But since SU doesn't return the bitmap data I'd have to write to file. And then there's no point in base64 encode it - I can just link to the temp file.

        I think this issue is worthy of a feature request.

        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

          Also -there is no .skm export it seems...

          multiple feature requests here it appears.

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

          1 Reply Last reply Reply Quote 0
          • N Offline
            NewOne
            last edited by

            Well, extra data in skm (the xml file) is not necessary to be encoded. We can store the texture as base64 and tiling, alpha as some parameters. And the material to be created inside ruby. πŸ˜’

            So the problem which stands: (how to) send raw bitmap data directly to sketchup via ruby?

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

              @newone said:

              Well, extra data in skm (the xml file) is not necessary to be encoded. We can store the texture as base64 and tiling, alpha as some parameters. And the material to be created inside ruby. πŸ˜’

              But there isn't any ruby API to export material to .skm, right? Or have I missed something?

              @newone said:

              So the problem which stands: (how to) send raw bitmap data directly to sketchup via ruby?

              Again, you have to save a temp file and load it.

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

              1 Reply Last reply Reply Quote 0
              • N Offline
                NewOne
                last edited by

                QUESTION: Does ruby have some debug methods which show the content of an object? If do, we could access what is behind of #<Sketchup::Material:0x6732f80> and do whatever we want wit that data. And I assume that the reverse could be possible as well.

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

                  @newone said:

                  QUESTION: Does ruby have some debug methods which show the content of an object? If do, we could access what is behind of #<Sketchup::Material:0x6732f80> and do whatever we want wit that data. And I assume that the reverse could be possible as well.

                  The Material object won't contain the bitmap data. It's more like a pointer to the interal SU data.

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

                  1 Reply Last reply Reply Quote 0
                  • N Offline
                    NewOne
                    last edited by

                    I found this http://www.imagemagick.org/RMagick/doc/#introduction Maybe is a way to have the texture image as blob inside ruby. If so, making the skm material with script is the easy part πŸ˜„ and can skip the part with "temp folder"
                    If any of you have time, throw an eye over it.

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

                      @newone said:

                      I found this http://www.imagemagick.org/RMagick/doc/#introduction Maybe is a way to have the texture image as blob inside ruby. If so, making the skm material with script is the easy part πŸ˜„ and can skip the part with "temp folder"
                      If any of you have time, throw an eye over it.

                      The whole reason we need to write to temp file is to get to the bitmap data in the first place.

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

                      1 Reply Last reply Reply Quote 0
                      • N Offline
                        NewOne
                        last edited by

                        Yes, I just noticed that is no use to have bitmap data as binary in ruby. Because when asigning texture image to a created material

                        
                        m = materials.add "mat1"
                        m.texture = "C;/texure.jpg"
                        
                        

                        We don't really add that texture, but pass the path to SketchUp and there, inside that evil 😑 thing some magic happens and it grabs the texture with the claws. So, yes... we need the bitmap as file on disk before any attempt to do anything. 😒

                        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