ScriptSpot

Forum topic · Scripts Wanted

If object name = something assign material

By 4strings4ever · 2014-08-01

Description

Hi all,

i'm looking for a way to look through all the scene objects and if an object name equals a specific name (ex. box01) then assign a material from a temporary matlib. I was able to create the temp matlib using the following code but can't make the selection part to work:

tempLib1 = loadTempMaterialLibrary "//Mylib/BOX01.mat"

matBOX01 = tempLib1[58]

$.material = matBOX01

meditmaterials[1] = matBOX01

thanks for your help

Comments (7)

Assign certain material to certain object ?

Wee · 2016-02-12

Above script is very useful, but how do i assign specific material to specific objects ?

For example,

material BRICK to Ex_wall
Material SHINGLE to Ex_Roof
....

thanks in advance.

.

miauu · 2016-02-12

Where are the materials located?

barigazy · 2014-08-01

If your material library is located in default "matlib" folder then you can use

matlib = loadTempMaterialLibrary ((getDir #matlib)+"\\your_library.mat")
-- if you know name of some specific material in your librari then you can use instead of index number real name
meditmaterials[1] = matLib["Some_name"]

d1myan · 2023-11-15

remove

d1myan · 2023-11-15

remove

barigazy · 2014-08-01


matLib = loadTempMaterialLibrary @"C:\Users\bga\Documents\3dsMax\materiallibraries\Walls.mat"
obj = getCurrentSelection()
index = 3 --3rd material in library
if obj.count > 0 and index <= matLib.count do meditmaterials[1] = obj.mat = matLib[index]

4strings4ever · 2014-08-01

Thanks that helped alot!