sketchucation logo sketchucation
    • Login
    šŸ¤‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Load and/or Save a SKM file to/from a model in Ruby

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 3 Posters 819 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.
    • Al HartA Offline
      Al Hart
      last edited by

      I asked this same question about 5 years ago but didn't find a solution:

      http://sketchucation.com/forums/viewtopic.php?f=180&t=9598&hilit=material#p60141

      But maybe things have changed since then.

      Has anyone done anything to work with SKM materials directly from Ruby.

      In particular - saving a material from the current model, or loading a material into the current model?

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        Got to the Code Snippets Index (by Author)

        ... and look under TIG

        šŸ˜‰

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • Al HartA Offline
          Al Hart
          last edited by

          Thanks Dan (and TIG).

          We will give this a try.

          Al

          Al Hart

          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
          IRender nXt from Render Plus

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

            The main issue is there is no simple 'zip' toolset within Ruby.
            My SKMtools use small single action 'jar' files to manipulate ZIP files [aka SKM] and also the related SKM Image files, so it will work cross platform. But of course the user needs to have Java installed and .jar files set to execute in that app, and not open in say WinZip!

            If you are just [re]zipping/unzipping SKM files then you can of course use two separate ways - for PC [via a temporary VBS written for each occasion] and for MAC [via a similar terminal shell-script, including some applescript] [Linux is similar but misses the osa part off] - which ca provide you with the desired zip/unzip methods - I use this approach in some more recent bespoke custom toolsets [but unfortunately these are subject to NDA and (c) and all within RBS šŸ˜ž ]...

            TIG

            1 Reply Last reply Reply Quote 0
            • Al HartA Offline
              Al Hart
              last edited by

              TIG,

              I see that the SKM stuff tries to store its temporary files in the install folder (typically the Plugins folder.)

              Have you had any problems with Windows 8, etc. which make it harder and harder for Apps to write to Program Files.

              Al Hart

              http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
              IRender nXt from Render Plus

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

                Yes, if I were to do it again today I'd make a plugin-specific subfolder in the ENV['TEMP'] folder [or OS equivalent] and then use that.
                My newer tools do that, if the user sets the Plugins folder Properties > Security > Edit to FULL Read/Write and lets it affect the contents too it works OK as it is... but a more robust solution using 'Temp'/'T' folders is a good idea if you are recreating the tool's functionalities from scratch...

                These tools are long over due an overhaul... I might look at fixing them when I have a free slot...

                TIG

                1 Reply Last reply Reply Quote 0
                • Al HartA Offline
                  Al Hart
                  last edited by

                  TIG

                  We were able to use the import and export stuff from SKM for our Material Schemes project.

                  We really appreciated the saving and loading of attributes, since the last time we checked (years ago), SketchUp was not reloading attributes properly when you save a material library and then placed the material in another library.

                  Material Names

                  Another relatively simple, but important change we made was to be able to import a material, specifying a name, and have it overwrite the material with that name if it already existed. The "secret" to this was to "escape" special characters in the material name with %XX, (the hex equivalent or the character), rather than replacing them all with underscore. Then we are able to determine the original name of the material in the model from the name of the saved .SKM file.

                  So a library material with a name like [Stone_Masonry_Multi] is saved into a SKM file with the name: %5BStone_Masonry_Multi%5D.skm, and we can then "unescape" the name back to [Stone_Masonry_Multi] when we import it.

                  Material Schemes

                  The whole idea of material schemes is to save .SKM files for all the materials in your model into a ZIP file (e.g. Light-Blue.scheme), then to modify the materials without changing the names, save another scheme and be able to load either scheme back into the model or into other models.

                  Al Hart

                  http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                  IRender nXt from Render Plus

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

                    'Collection' ZIPs...
                    Presumably you can use the /zip/unzip/ jar files with suitably formed ini files to do this for you?
                    They will work with ZIP/RBZ/SKM/Style etc

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • Al HartA Offline
                      Al Hart
                      last edited by

                      The zip JAR's weren't working on one of my machines - either because Java is not installed - or because the JAR extension is being grabbed be Firefox.

                      We decided to include 7zip instead and use it for zip.

                      Al Hart

                      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                      IRender nXt from Render Plus

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

                        That's a work around if Java's not available...
                        Sometimes decompression tools also hijack .JAR extensions !

                        If you are using PC only you can use VBS with 'unzip' 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