Loading a Material from SKM
-
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 -
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.
-
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/
-
for dezip see code.plugins.ro
I hope that in SU7 we will have an API for accessing .skm file
-
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?
-
Even better: Found the defintions.load method that will load the model into the list of definitions which then loads the materials.
Advertisement