Materials name problem in Sketchup 2025

Hi,
When I try to save a material name for example it save “Plaster_03_1K1” but in the materials name list we can only find Plaster_03_1K. It happen for some materials. Do you know why it happen?

1 Like

I couldn’t replicate this behaviour.
Can you provide your simple code snippet how do you “save material name” and how do you generate that name list?

Thank you for your attention.

        mat_file = []
        if @win
          mt_dir = Sketchup.find_support_file("Materials")
          prog_mt_dir = mt_dir.gsub( ENV["APPDATA"].gsub(/\\\\|\\/,'/'),
          ENV["PROGRAMDATA"].gsub(/\\\\|\\/,'/'))
          Dir.chdir(mt_dir) do
            Dir.glob("**/*.{skm,SKM}") { |mt| mat_file << (File.join(mt_dir, mt)) }
          end
        else
          mt_dir = Sketchup.find_support_file("Materials/Colors")
          prog_mt_dir = File.dirname(mt_dir)
        end
        mat = Sketchup.active_model.materials
        Dir.chdir(prog_mt_dir) do
          Dir.glob("**/*.{skm,SKM}") { |mt| mat_file << (File.join(prog_mt_dir, mt)) }
        end
        mat_names = []
        mat_file.each { |mt| mat_names << File.basename(mt,".skm") }
        p mat_names

This code give us list of materials.

in this link you can see material name change inside SU. (“Plaster_03_1K” change to “Plaster_03_1K1” when use it.)

The mat_names here is an Array of file names (without suffix), and not necessarily the material name in it. Definitely not the list of material names which has been loaded into the model, as sown in the screenshot above.

I have no access to code on your Google drive.
If you change the material name inside SU, you need to save it to that directories with file name of that material, then you can retrieve the names from the file names.

You can also get the actual (loaded) material names inside SU, e.g. by:

materials = Sketchup.active_model.materials
mat_names = materials.map(&:name)
1 Like

Mat name is correct and you can see the output in the above picture. Also, I wanted to add all available materials not just loaded materials. Did you see the video? Any idea why material name change. Is it a bug in SU or my problem. I never faced such problem in SU2024 and older..

Did you actually read my previous post?
I have no idea what is in your Google drive, video or what. I do not have permission and I will not share my email address with you to ask for it. Put the information to your post or share it in other way.

Let me change video format and share it here.


some materials have this problem and some not.

Once again, I hope you will get what I’m talking about.

The mat_names here is an Array of file names (without suffix), and not necessarily the material name in a model. Definitely not the list of material names which has been loaded into the model, as sown in the screenshot or video above.

Import this materiel file into your model,
Plaster_03_1K_new.skm (3.7 MB)

… and compare the material name in a model to the file name.

Do you see the differences?
You are trying to get the material name by file name, which is obviously not always the right way.

3 Likes

A material skm is actually a zip archive. Among its contents is a file called document.xml which contains an element giving the name of the material. Presumably this is because anyone can change the name of a file outside of SketchUp. It’s reasonable to ask why someone (or some app) would do that, but the fact remains that it is possible. So, processing the filenames is not a reliable way to discover material names.

1 Like

There are 2 problems. One is the material name list. You explain about it and I will correct my code as you suggest. The other problem is material name change inside SU. Please see the video again, when I select the material its name is Plaster_03_1K but when I use this material suddenly its name change to Plaster_03_1K1 (one ‘1’ add to the end). Then in my code when I save this material Plaster_03_1K1 will save. If I do the same with for example Wood_Floor_01_1K this problem will not happen and everything works well. This problem happen inside SU and my code is innocent.

I cant reproduce this. Neither with Concrete_04_1K as in your video. Also tested with other couple of random one…no such an issue here.
. :thinking:
Don’t you have an Extension installed, that can cause this renaming?

mat_test

1 Like

Wall.skp (15.2 MB)
This file has the same problem.

I see. You have a material in model and that was renamed. If you select material from the list and this one have same base file that already applied one, the applied material will be “prioritized” to use.
How to reproduce:

  • Select one of the new PBR material, and apply to face
  • Rename it by adding "1’ ad the end
  • Select again the above PBR material from the list, and apply to face >> The renamed version will apply

However If you select a classic material this behaviour cant be reproduced:

mat_test2

I guess this is a bug in the NEW material handling.

@colin ?

2 Likes

Both the "Colors" and "Colors-Named" material subfolders were secretly* removed with the SketchUp 2025.0 release.

They have been replaced with the new PBR material subfolder which is named "Solid Colors".


* “Secretly” means that this change is not revealed in the 2025.0 Release Notes. [Apparently the product manager(s) want the users to “discover” the new PBR color materials with the new “fun” names. (Note that these new color names do not follow the W3C/X11 standard color names.)]

2 Likes

I asked a question of the developers before 2025.0 release, but it has yet not been answered or acknowledged.

In all previous SketchUp versions, the distributed “native” materials names were delimited with square brackets, like: "[Concrete Scored Jointless]" if you accessed it using Material#name().

But if you asked the material for it’s display name using Material#display_name(), the string returned without the square brackets, viz: "Concrete Scored Jointless".

The Ruby API documentation makes no mention of this deviation from historical norm.

2 Likes

I think that this is wanting to achieve what I already coded two months ago.
(See attached code - below since moved to it’s own topic.)

Code quoted from Majid866 above ...

This is particularly ugly code …

Try using these 3 methods I wrote:

[code] Accessing and Loading SketchUp Shipped Materials - Developers / Ruby API

2 Likes

I’ve tried this approach before, but unfortunately, it turned out to be more complicated than expected. If I remove the extra “1” character, the software does find the material from the list — but the color changes when I apply it.

Dezmo, thank you for your attention and help. As shown in the video, I used MAJ_FollowMe to pick a profile and its material, then applied it. I did the same for two different materials in separate groups. One material works perfectly, but the other not only changes color in the newly created 3D object, it also affects the color of other 3D objects that use the same material.

Your code works well. You use interesting way to distinguish SU version.(MaterialTemplate.skp).
Thank you Dan

Thank you. I got it from the API documentation.