Automatic Assign Materials to Objects from Library

Hello guys,
maybe a script like that exists already, maybe I'm just searching with the wrong keywords...

Anyway, I'll try to explain what I need to do and maybe you can suggest me the fastest procedure or script!!! (sorry for my bad English grammar, I'm from Italy...)

Basically I've a rigged model of a robot with MANY sub-objects. That model has been animated in Maya and when returning to Max for final render it looses many materials properties, so I need to re-assign materials to each of the hundreds components.

It's for a short film that has approx 100 shots and each shot it's a Maya file and I don't want to repeat the procedure again and again...

I've a Max library with all my materials, the bothering part is to repeat the procedure for each shot of the film: selecting the object, assigning the material from the library, repeat...

Since the sub-objects of my robot are always the same, I wonder if there's a way for me to assign the materials only one time, then store somewhere the material properties of each sub-object and when I import the new scenes simply paste what I stored previously.

Is that possible? How? Do I need to write a custom script with each object name? If so, can you tell me how?
Or is there a script that do this automatically somehow, maybe selecting first all the objects in the scene, then "copy materials attribute" or something...?

THANKS A LOT!
Nicola

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dl80802's picture

.

hi
i have obj or fbx... file
i import this geometry to scene, scene have material creating before

i need replace import geometry material to scene material. material in import file have same name material in scene.

how i may do this?
(options? script?....)

miauu's picture

.

Try this:
1- load your scene. Apply proper materials to all objects.
2- run this script:

(
	global rol_transferMaterials
	try(destroyDialog rol_transferMaterials)catch()
	rollout rol_transferMaterials "miauu"
	(
		global allObjsNamesArr = #()
		global allObjsMatsArr = #()
 
		button btn_getMats "Get materials" width:140
		button btn_pasteMaterials "Apply materials" width:140
 
		on btn_getMats pressed do
		(
			for o in objects where (oMat = o.material) != undefined do
			(
				append allObjsNamesArr o.name
				append allObjsMatsArr oMat				
			)
		)
 
		on btn_pasteMaterials pressed do
		(
			if allObjsNamesArr.count != 0 do
			(
				for o in objects do
				(
					if (idx = findItem allObjsNamesArr o.name) != 0 do
					(
						o.material = allObjsMatsArr[idx]
					)
				)
			)
		)
	)
	createdialog rol_transferMaterials 
)

3- press the Get materials button
4- DO NOT CLOSE THE SCRIPT
5- do what you have to do with the loaded scene
6- load new scene
7- press the Apply materials. If you do not have objects with the same names the script have to apply the proper materials to the objects in the new scene.

Check if the script transfer the materials properly and do not close the script. Otherwise you will have to load a scene with properly applied materials and to press the Get materials button again.

pfbelesa's picture

Library to Sample Spheres

I'm currently exploring a more streamlined approach to manage my collection of works, which includes a variety of unique materials I've personally developed, some exceeding thirty in number.

I'm interested in discovering if there exists a script capable of extracting each material from a .max file and applying it to a singular sample sphere within my current scene. Essentially, my goal is to initiate a new scene file, import my previously created materials as libraries, and have the script automatically generate individual spheres, each measuring 1 meter in diameter, to which a distinct material is applied.

For example, should I import a .max file into the material editor that contains 50 materials, the script would then create 50 spheres, each adorned with one of the materials.

Would it be possible to achieve this? I greatly appreciate your time and assistance in this matter.

SimonBourgeois's picture

Script to import materials from a .max file into current file

Hi pfbelesa,
This script https://www.mediafire.com/file/lknqnl7mlruq8ab/ImportMaterialFromFile.mc... will do what you need.
drag and drop the file in 3dsmax viewport then go to customize, customize user interface, then you will find it in SimonScript category.

pfbelesa's picture

Library to Sample Spheres

I'm currently exploring a more streamlined approach to manage my collection of works, which includes a variety of unique materials I've personally developed, some exceeding thirty in number.

I'm interested in discovering if there exists a script capable of extracting each material from a .max file and applying it to a singular sample sphere within my current scene. Essentially, my goal is to initiate a new scene file, import my previously created materials as libraries, and have the script automatically generate individual spheres, each measuring 1 meter in diameter, to which a distinct material is applied.

For example, should I import a .max file into the material editor that contains 50 materials, the script would then create 50 spheres, each adorned with one of the materials.

Would it be possible to achieve this? I greatly appreciate your time and assistance in this matter.

chaosmonger's picture

Same thing for modifiers?

Hello... I was wondering... can exact the same thing be done for the stack modifiers?
Like I open my scene, I click "get modifiers", then open the new scene and "apply modifiers" to the same name objects?

miauu's picture

.

No. Some modifiers, like Edit Poly for example, can't be copied properly using maxscript.

chaosmonger's picture

But Turbosmooth and Normals?

I'm actually talking of instanced modifiers, like Turbosmooth or Edit Normals.

chaosmonger's picture

Thanks a lot miauu! Works

Thanks a lot miauu!
Works perfectly!!!!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.