How to add all SU materials in our list?

The answer is no. Because it would be a waste of time and effort.
As shown above a programmer can load any of the distributed materials.

If you wish to, it is rather easy to use the core Ruby Dir class to search through the material collections on disk and return the file path.

Example …

  # Returns the absolute path to a material name query,
  # or nil if the named material was not found.
  def get_material_path(matl_name)
    # Search User Materials first:
    user_path = Sketchup.find_support_file("Materials")
    found = search_materials(user_path, matl_name)
    if !found  # Search ProgramData Materials:
      matl_path = Sketchup.find_support_file("Materials/Colors")
      prog_path = File.dirname(matl_path)
      found = search_materials(prog_path, matl_name)
    return found

  # Recursively searches the material path given for the named material.
  # Do not include the .skm extension, just the name.
  def search_materials(matl_path, matl_name)
    skm = File.join("**", "*.skm")
    skm_files = []
    Dir.chdir(matl_path) { skm_files = Dir.glob(skm) }
    rel_path = skm_files.find do |file|
      File.basename(file,'.*') == matl_name
    rel_path ? File.join(matl_path,rel_path) : nil

So for example …

bamboo_path = get_material_path("Wood Bamboo")
#=> C:/ProgramData/SketchUp/SketchUp 2021/SketchUp/Materials/Wood/Wood Bamboo.skm
1 Like