I'd like to rename all the materials in a selection of meshes whether that be multisub materials or not. Is this feasible to do?
Forum topic · Scripts Wanted
Rename Materials To Diffuse Texture Name
By Miles · 2014-01-24
Forum topic · Scripts Wanted
By Miles · 2014-01-24
I'd like to rename all the materials in a selection of meshes whether that be multisub materials or not. Is this feasible to do?
Comments (19)
Comment policy
Tell me which material do you want to rename (Standard, Arch&Design, VRayMtl)?
Just standard for them.
This supports all tree ;)
fn renameMats objs = if objs.count != 0 do
(
local matClasses = #(Arch___Design__mi, Standard, VRayMtl)
local selMats = #()
for c in matClasses do
(
for o in objs where o.mat != null do (join selMats (getClassInstances c target:o))
)
if selMats.count != 0 do
(
for m in selMats do
(
case of
(
(isProperty m #diff_color_map): if isKindOf (map = getProperty m #diff_color_map) textureMap do m.name = map.name
(isProperty m #diffuseMap): if isKindOf (map = getProperty m #diffuseMap) textureMap do m.name = map.name
(isProperty m #texmap_diffuse): if isKindOf (map = getProperty m #texmap_diffuse) textureMap do m.name = map.name
)
)
) ; free selMats
)
renameMats selection
-- Frame:
-- selMats: #(wap_mapA_gate_nos_.xno0:Standard, wap_mapA_gate_nos_.xno1:Standard, wap_mapA_gate_nos_.xno2:Standard, wap_mapA_gate_nos_.xno3:Standard, wap_mapA_gate_nos_.xno4:Standard, wap_mapA_gate_nos_.xno5:Standard, wap_mapA_gate_nos_.xno6:Standard, wap_mapA_gate_nos_.xno7:Standard, wap_mapA_gate_nos_.xno8:Standard, wap_mapA_gate_nos_.xno9:Standard, wap_mapA_gate_nos_.xno10:Standard, wap_mapA_gate_nos_.xno11:Standard, wap_mapA_gate_nos_.xno12:Standard, wap_mapA_gate_nos_.xno13:Standard, wap_mapA_gate_nos_.xno14:Standard, wap_mapA_gate_nos_.xno15:Standard, wap_mapA_gate_nos_.xno16:Standard, wap_mapA_gate_nos_.xno17:Standard, wap_mapA_gate_nos_.xno18:Standard, wap_mapA_gate_nos_.xno19:Standard, ...)
-- objs: $selection
-- matClasses: #(Arch___Design__mi, Standardmaterial, undefined)
-- VRayMtl: undefined
-- Type error: getClassInstances requires MAXClass, got: undefined
Not sure what happened. I just selected all the meshes and tried executing it. Unless thats not the correct way to go about using this.
Yup. You not have installed VRAY.
Try this then
fn renameMats objs = if objs.count != 0 do
(
local matClasses = #(Arch___Design__mi, Standard)
local selMats = #()
for c in matClasses do
(
for o in objs where o.mat != null do (join selMats (getClassInstances c target:o))
)
if selMats.count != 0 do
(
for m in selMats do
(
case of
(
(isProperty m #diff_color_map): if isKindOf (map = getProperty m #diff_color_map) textureMap do m.name = map.name
(isProperty m #diffuseMap): if isKindOf (map = getProperty m #diffuseMap) textureMap do m.name = map.name
)
)
) ; free selMats
)
renameMats selection
Thats awesome, works perfectly now. Only thing I would like it to get rid of would be the added extension that is added to it.
.dds-image It adds this depending on if its a png or jpg. Is there a way to just make it search for it and just delete it.
u want to remove extension from material name?
Like this?
"somename1.dds" -->"somename1"
"somename2.jpg" -->"somename2"
This fn will remove extension from material name
fn renameMats objs = if objs.count != 0 do
(
local matClasses = #(Arch___Design__mi, Standard)
local selMats = #()
fn cleanName str =
(
if (strarr = filterstring str ".").count < 3 then return strarr[1] else (for i = 2 to strarr.count-1 do strarr[1] += ("."+strarr[i]) ; strarr[1])
)
for c in matClasses do
(
for o in objs where o.mat != null do (join selMats (getClassInstances c target:o))
)
if selMats.count != 0 do
(
for m in selMats do
(
case of
(
(isProperty m #diff_color_map): if isKindOf (map = getProperty m #diff_color_map) textureMap do m.name = cleanName map.name
(isProperty m #diffuseMap): if isKindOf (map = getProperty m #diffuseMap) textureMap do m.name = cleanName map.name
)
)
) ; free selMats
)
It executed fine, but it just didn't change anything.
Would still leave the material name like this.
wap_meca03_dfsp_o.dds-image
And if I try it how the material name normally is it won't change anything at all.
Not sure if its just because its a MultiSub Materials or not.
this will only rename Standard and A&D material name but not multimaterial
probably you forget to run this line after you run previous fn
renameMats selection
Physical material and materials in multimaterial
Hi! tell me: is it possible to fix this script so that it works with Physical material too and with materials in multimaterial?
Hi
you can use this:
I added an optional argument to use texture names instead of map names,just use texturename:off if you need the map name rather than the texture filename.
It will check for any bitmap texture in the material that has a file path and use the first found bitmap file name as a material name
Hi! tell me: how do I add Physical material here?
script to remame textures
I have searched scriptspot and I have not found any script that changes the name of the textures in max and that at the same time rename these in the hard disk in a massive way because often the 3d models contain textures and maps with names numbers and even Chinese letters , Russians that are a total mess, I hope you could create a script that can do this, rename textures in max and in the hdd and update automatically in the routes.
I hope it's understandable because I'm using the Google translator
This is a very good idea.
.
Read this thread. The script is at the last post.
https://forums.autodesk.com/t5/3ds-max-forum/rename-texture-files-but-ke…
Greetings miauu
I have dealt with Interactive Universal Renamer and the best free option
I can find is duber bitmap collector but it has not been updated, hopefully with your knowledge you could modify it and improve it in these points: when renaming the textures and maps are not duplicated, when opening it load automatically the textures without having to look for the route in the browser, be able to sort them alphabetically and the option of saving the new name in the same input folder automatically.