Get Materials for Selected Objects and create Multi-Material?

Hi everyone, I currently have an object with a multi material attached. Problem is this multi material is very large because it was designed to span over say a whole level.

Does anyone know of an existing script where I could copy just the materials used from a selected object and then put those materials into a new multi-material?

Any help is much appreciated :)

K

Comments

Comment viewing options

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

Hey and thanks, I tried out

Hey and thanks, I tried out the script but it didnt really do what I was looking for. I am looking to strip down the multi-material so that it only has material slots which represent the materials on a selected object.

Cheers, K

le1setreter's picture

here a quick solution. not

here a quick solution. not really optimized or hardly tested and works on edit mesh/poly objects only, but maybe it is a good start:

-- clearListener()
 
try (destroyDialog ro_multimatStrip)catch()
 
rollout ro_multimatStrip "Multimaterial Stripper" width:160 height:30 (
 
	local mySelObj
	local mySelObjMat
	local myNewMat
	local idlist = #()
 
	pickbutton chooseObj "pick object" width:140 tooltip:"pick the object to generate new multimat"
 
 
	fn createNewMat = (
 
		local idlist = #()
 
		if (classof mySelObj == Editable_Poly) OR (classof mySelObj == PolyMeshObject) do (
 
			num_faces = polyop.getNumFaces mySelObj
 
			for x = 1 to num_faces do (
				appendIfUnique idlist (polyop.getFaceMatID mySelObj x)
			) -- end for
 
		) -- end if edit poly
 
 
 
		if (classof mySelObj == Editable_mesh) DO (
 
			num_faces = getNumFaces mySelObj
 
			for x = 1 to num_faces do (
				appendIfUnique idlist (getFaceMatID mySelObj x)
			) -- end for
 
		) -- end if edit poly
 
 
		myNewMat = multimaterial numsubs:idlist.count name:"newMultimaterial"
 
		for k = 1 to idlist.count do (
			myNewMat.materialIDList[k] = mySelObjMat.materialIDList[idlist[k]]
			myNewMat.names[k] = mySelObjMat.names[idlist[k]]
			myNewMat.materialList[k] = mySelObjMat.materialList[idlist[k]]
		) -- end for
 
		mySelObj.material = myNewMat
		messagebox("New Multimat is assigned to object!")
	) -- end function "createNewMat"
 
 
 
 
	-- if object is picked:
	on chooseObj picked obj do( 
 
		if obj != undefined AND isKindof obj.material Multimaterial then (
 
			chooseObj.text = obj.name
 
			mySelObj = obj
			mySelObjMat = obj.material
 
			createNewMat()
 
		) else (
			messagebox("object has no mutlimat")
		) -- end if "multimat"
	) --end on
 
) -- end of ro_multimatStrip
createdialog ro_multimatStrip
barigazy's picture

Comment viewing options

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