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

    Extract Material thumbnail?

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 3 Posters 1.1k 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

      πŸ‘Š Another project stomped due to lacking API. X_x grrr...

      The thing is- I don't want to extract the full texture. They can be very large.
      I need to get the thumbnail for my recreation of the Material browser. I don't want to extract 50 large textures and send it to the webdialog. That would just slow it right down - plus take up extra disk space.

      The thumbnails is what I need. They are small enough so you can pass them directly to the webdialog without saving them to disk - using data URIs which IE8 finally support, provided they are under 32KB.

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

      1 Reply Last reply Reply Quote 0
      • AdamBA Offline
        AdamB
        last edited by

        Its stored in "doc_thumbnail.png" in the SKM file.

        But can we see you "throwing a fit" for entertainment value?

        Developer of LightUp Click for website

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

          @adamb said:

          But can we see you "throwing a fit" for entertainment value?

          Why yes you may. I can manually get the thumbs from an skm file - but not from Ruby during run time. 😞 So stand by for a fit.

          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

            If you have the SDK you'll see there are methods for getting/saving thumbnails [url]file:///C:/Program%20Files/Google/Google%20SketchUp%207/sdk/SkpReader/documentation/interface_i_skp_thumbnail_provider.html[/url] [path might differ on your PC]
            But you'll then need to compile a C++ applet to give the new method material.thumbnail!
            Capture.PNG

            TIG

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

              But isn't that thumbnails for .skp files? Like Sketchup.save_thumbnail http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/sketchup.html#save_thumbnail
              ❓

              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

                The think that SDK's ISkpThumbnailProvider code is applicable to any object supporting a thumbnails - like Components and Materials...Capture.PNG

                TIG

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

                  And this C++ voodoo can be used at run-time?

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

                  1 Reply Last reply Reply Quote 0
                  • AdamBA Offline
                    AdamB
                    last edited by

                    Just open the file from Ruby and rip out what you want, whats the problem?

                    Developer of LightUp Click for website

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

                      ❓
                      I think you'd need to make an add-on that loads at startup that provides extra methods like the Exporters do like Skp2Acad.dll [presumably something else on a Mac!]- in this case say export(material.thumbnail,"filepath") ❓
                      Not sure - it's a bit outside my remit............
                      You can also find the material's texture inside the SKP file's data but then getting it's thumbnail and the 'bits' is beyond me... 😞

                      TIG

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

                        @adamb said:

                        Just open the file from Ruby and rip out what you want, whats the problem?

                        But how - how do we find the particular material, then its texture and then its thumbnail within the mess of SKP data... ❓ πŸ˜•

                        TIG

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

                          @adamb said:

                          Just open the file from Ruby and rip out what you want, whats the problem?

                          Because that would require the user to save the model before the script would be able to extract the thumbnails.
                          As mentioned - I'm trying to make a replacement for the material browser - so I need to get the material thumbnails at run time from the open model.

                          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

                            @thomthom said:

                            Because that would require the user to save the model before the script would be able to extract the thumbnails.

                            Also - material thumbnails doesn't appear to be stored in the .skp file... 😞

                            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

                              The material thumbnails are stored in the .SKM files [which is actually '.ZIP' files].
                              You can export a material's texture's image-file quite easily using existing API methods... and use that as your image... OR extract the thumbnail from the .SKM file as if it were a 'zip' using Ruby 'zip' methods'... πŸ˜•

                              TIG

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

                                @tig said:

                                You can export the material's texture's image-file quite easily using existing API methods
                                Original size - which might be huge. Not ideal for a material browser which would then load lots of full size images and only display it at a fraction of its size.

                                @tig said:

                                OR extract the thumbnail from the file as if it were a 'zip' using ruby 'zip' methods'...
                                But there isn't a way to get in-model materials exported as .skm via Ruby, is it? ❓

                                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

                                  If you get a 'large' image there are Ruby tools to down-size it into a thumbnail ???
                                  http://rmagick.rubyforge.org/
                                  http://snippets.dzone.com/posts/show/3621
                                  http://oldwiki.rubyonrails.org/rails/pages/HowtoCreateThumbnailImages
                                  etc etc............

                                  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