Is there a way to bring the materials from the sketchup to the list?

I’m making Ruby plug-in and I’m just curious.
I’m going to insert the material on a specific side.
But what I want is that there are various materials in the sketchup, so is there a way to show the list of materials?
For example, if you use the corresponding code in the current image, only the material used in the sketchup will be shown as a list, and I wonder if there is a code that can bring materials like “Metal Rusted” to the list from the beginning.

The #materials method returns a collection of all of the materials in the model. But only contains that materials which already loaded to the model.

You have to use the #load method first to be able to “list” the materials.

There was an extensive discussion about it recently::
How to add all SU materials in our list? - Developers / Ruby API - SketchUp Community

Instead of putting the screenshot of your code, I would like to ask you to use this guide:
and post the code accordingly… :innocent:

1 Like

loads the specified material from its SKM file - you need to know its full path.
You can get that using the File… methods in Ruby.
It it’s already loaded it returns that existing material instead of the new one…
You’ll need to trap for the error when it doesn’t succeed…