How to fetch all material in SKP via Ruby?
-
Hi,
Is it possible to fetch all material items which are appear in the Sketchup materials window by ruby?
Is there any function which do the above work ie which can access the all items(material type) in the Materials?I found that the below function which works for Model-
model = Sketchup.active_model matrials = model.materials materials[0].name ==> gives name of the material
Like this above any other function by which we can retrieve the all Material items which are present in Sketchup Materials(class index).
-
You can only access the Materials that are loaded into the Model.
You can iterate the list and get various aspects of the material.Sketchup.active_model.materials.each{|material| puts material.name puts material.display_name puts material.color puts material.alpha puts material.texture ### and so on... puts }
I have included the puts so the info is shown in the Ruby Console but of course you can do other things with that...
A Material's '.display_name' is not always the same as the '.name' [depends on its creation/source]
A Texture can also be further probed to get info like its image, size and so on...Read the API http://www.sketchup.com/intl/en/developer/docs/classes.php
If you must get details of SKM files not yet loaded [and not loadable using native API methods] then you could look at my SKMtools which offer many additional tools to import/export/interrogate SKM files etc...
But please learn to walk before you run
Advertisement