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

SKM files

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 4 Posters 2.6k 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.
  • J Offline
    JonD
    last edited by 16 Nov 2010, 04:36

    OK, I know there are some older posts out there, so this is a long shot...Is there a way to load SKM files and add them to the Sketchup.active_model.materials collection? I have tried some of the obvious methods, but have not had luck. I am trying to save some attributes in an attribute library attached to the material. I can see that the attribute library is saved in the skm file (changed it to zip and looked at the xml). It also reloads the attributes correctly when I use it from the material window - so it basically works. I would like to apply the materials to some of the object using ruby...

    Jon

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 16 Nov 2010, 07:43

      Nope - via the Ruby API we are unable to Read/Write .skm files. 😞

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

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 16 Nov 2010, 10:09

        If you use convoluted zip commands not available in SUp Ruby but available in the broader Ruby world... then you can read/write external SKM files - but awfully complicated.
        If you want to load materials from known external SKM files there is a 'trick'.
        Make a SKP file with just one face in it divided into several parts and apply the required materials to each part in turn.
        Those Materials are added to that SKP's model.materials list
        Purge the Model.
        Erase all of the face/facets so the SKP is now empty, save for the now unused model.materials.
        Add a cpoint [or any small geometry] at the origin [this is because you can't import an empty SKP later on]
        Save/close the SKP as 'MyMaterialsToImport.skp' - or whatever name you fancy.
        Now whenever you want to load your Materials you use something like this...
        model.start_operation("Import Materials") defs=model.definitions.to_a model.import(path_to_MyMaterialsToImport.skp) defn=(model.definitions.to_a - defs)[0] defn.entities.erase_entities(defn.entities.to_a) model.commit_operation
        The start/commit is needed to remove the emptied temporarily imported SKP/Compo defn from the Browser and tidy up.
        The materials are now available in the model.materials list for use...

        The above method batch imports Materials BUT of course you could make one SKP named after each SKM with just that material in it and then import them individually as needed...

        If you often use materials you can of course add them to your SKP templates as first described above - erasing temporary faces etc [my Templates do indeed already have several empty Layers, two Styles and a few commonly required Materials already in them so at startup you don't need to make or to load them from outside sources]

        TIG

        1 Reply Last reply Reply Quote 0
        • J Offline
          JonD
          last edited by 22 Nov 2010, 23:06

          Thanks for the good information. Has anyone submitted an enhancement request to Google for some SKM read/write api?

          Jon

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 23 Nov 2010, 07:09

            Yea, but keep nagging them. πŸ˜‰

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

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 23 Nov 2010, 09:49

              I'm currently looking at a cross-platform way of reading/writing skm's using a Java app, and a cmd/terminal files [for PC/MAC] - I already use something similar in the Octane Render exporter that needs to run that exe with arguments on all platforms.
              I know I can extract images [and thumbnails], and get the xml contents, to clone the skm into the skp, but I need to get it working less clunkyly - without user input...
              If I ever get anywhere near so solution I'll post something.

              It would just be easier it they built it in but I suspect that Google have other fish to fry...

              TIG

              1 Reply Last reply Reply Quote 0
              • 3 Offline
                3eighty
                last edited by 24 Nov 2010, 06:13

                Um...What program uses an SKM file?

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 24 Nov 2010, 07:38

                  SketchUp! πŸ˜‰

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

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 24 Nov 2010, 09:40

                    @3eighty said:

                    Um...What program uses an SKM file?

                    It's a SKetchup-Material file - didn't you ever look in your Materials folder πŸ˜’

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • 3 Offline
                      3eighty
                      last edited by 24 Nov 2010, 22:36

                      Just wanted to be sure you guys were alert..... 😳 πŸ˜’

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 / 1
                      • First post
                        8/10
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement