sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Loading a Material from SKM

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 5 Posters 878 Views 5 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.
    • M Offline
      mocathe1st
      last edited by

      Hi all,

      I was just wondering if anyone knows how to load up a Material from it's SKM file.

      I've got a whole bunch of materials (saved as .SKM files) that contain attributes and which I need to be able to load up and assign to faces programmatically. It is no problem to do this manually, but I can't find a way of doing this via the Ruby API. 😞

      Any ideas???

      Thanks very much,
      Malcolm Murray

      1 Reply Last reply Reply Quote 0
      • R Offline
        RickW
        last edited by

        It can be done, but it is a bit of work. You need to extract the image from the subfolder in the .skm file. I've done this in an experimental situation, but not in anything ready for distribution.

        RickW
        [www.smustard.com](http://www.smustard.com)

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

          A skm file is really a zip file.
          You need to make a temporary copy of the skm and rename with a .zip suffix and then require the "dezip.so" socket and run some commands using it (PC only) - it is out there somewhere - if I recall correctly TBD sent me a copy ? ***
          Then you can find the image (say jpg or png) [NOT thumbnail] and get its contents.
          Write this to a new file with the right name.
          You have the jpg data extracted.

          *** RubyZip is also available: http://rubyforge.org/projects/rubyzip/

          TIG

          1 Reply Last reply Reply Quote 0
          • tbdT Offline
            tbd
            last edited by

            for dezip see code.plugins.ro

            I hope that in SU7 we will have an API for accessing .skm file

            SketchUp Ruby Consultant | Podium 1.x developer
            http://plugins.ro

            1 Reply Last reply Reply Quote 0
            • F Offline
              fizgig
              last edited by

              A quick workaround that would work for me is to load a model of a cube or something that has the needed materials mapped to its faces so the materials should load with it.

              The script should load the model and then delete it leaving, hopefully, the materials behind. Trouble is, the Sketchup.active_model.load command requires the user to physically drop the cube into the scene before it can go forward. I'd much rather load it to 0,0,0 or something and then delete it before the user sees it. Anyone know how to do that?

              1 Reply Last reply Reply Quote 0
              • F Offline
                fizgig
                last edited by

                Even better: Found the defintions.load method that will load the model into the list of definitions which then loads the materials.

                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