Hopelessly stuck: Replacing geometry of same name while keeping material of different name

Good Saturday morning to you all!

I am working towards a tight deadline, ran into a problem I thought I could solve easily and got hopelessly stuck. I'm hoping to find a genius here who xan help me out.

I have 15 .max files exported from Revit. Each file contains the same highrise building at a different stage during construction. I have the last stage, the finished building, mapped and shaded in 3D Studio Max with Vray materials.

My original plan was to import each of the other .max files into that finished scene, replace the geometry of the finished building with the geometry of the importing file and automatically have the mapping and material of the finished building applied to the merging geometry with the same name. Turns out that doesn't work because my Vray materials don't have the same name as the Autodesk materials in the importing .max files. So I can merge or replace all geometry, but I can't automatically apply my mapping and materials to merging objects with the same name. They judt keep their original Autodesk material. Right now it looks like I will have to manually apply the mapping and materials to each one of the 15 .max files, and I just think there must be a way this can be done. I'm a beginner maxscripter, so I am asking you more advanced people: Could a script help me do this?

If any of you can help or advise, I would be incredibly grateful.

Thank you so much in advance.
Dagi Cueppers

Comments

Comment viewing options

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

`

Hi, try this... after importing new objects... Select source object first (uvmapped and with new materials)
then run this script:

(
	local sArr = for o in selection collect o
	local sArrNames = #()
	for i = 1 to sArr.count do sArrNames[i] = sArr[i].name
 
	for o in objects where finditem sArr o == 0 do 
		(
			a = finditem sArrNames o.name
			try( o.material = sArr[a].material )catch()
			try( addModifier o sArr[a].modifiers[#UVW_Map] )catch()
		)
)

It search in entire scene for objects with the same name as selected obj (if found apply material and uvmodifier from source object).

Let me know how it works.
Cheers,

Comment viewing options

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