Notifications
Clear all

[Closed] Changing MaterialIDs Scripte ???

I have a big scene with 4900 cars, all instences

I have a base of 14 differents cars, with one Multi/Sub

I “only” need to change the IDs from MaterialID 1 to 44 to ID 71 to 115…

I have 14 cars to change…
the 4900 cars are base on the 14 cars…

For exemple
Car 1 : ID1 ID2 ID15 ID20 ID14
Car 2 : ID3 ID4 ID15 ID20 ID14
Etc…

Is there an easy way to do that… A script or something ?

Please Help this is an emergency…

Best regards…

5 Replies
 rdg

this is for editbale_mesh:

it adds a offset to the materialId of each face in a editable_mesh object:

(
	-- the settings
	
	matIDoffset = 2
	
	-- the script
	theSel = selection as array
	for theObj in theSel do(
		if classof theObj == Editable_Mesh then (
			theNumFaces =  getNumFaces theObj
			print theNumFaces
			for theFace = 1 to theNumFaces do (
				theCurrentMatID = getFaceMatID theObj theFace
				setFaceMatID theObj theFace (theCurrentMatID + matIDoffset)
				format "%: % %
" theObj.name theFace (theCurrentMatID + matIDoffset)
	
			)
			update theObj
		)else(
			print "Object is not Editable_Mesh"
		)
	)
)

Georg

Thanks… I will test it…

Thanks a lot…

Thanks a lot man…

Your script work perfectly…

Many many thanks…

I’m just wondering if it’s difficult to adapt for editable poly ?

 rdg
(
	-- the settings
	
	matIDoffset = 2
	
	-- the script
	theSel = selection as array
	for theObj in theSel do(
		theObjType = classof theObj
		case theObjType of (
			 Editable_Mesh:(
				theNumFaces = getNumFaces theObj
				for theFace = 1 to theNumFaces do (
					theCurrentMatID = getFaceMatID theObj theFace
					setFaceMatID theObj theFace (theCurrentMatID + matIDoffset)
					-- format "%: % %
" theObj.name theFace (theCurrentMatID + matIDoffset)
		
				)
				update theObj
				)
			Editable_Poly: (
				print "Object is POLY"
				theNumFaces = getNumFaces theObj
				for theFace = 1 to theNumFaces do (
					theCurrentMatID = polyOp.getFaceMatID theObj theFace
					polyOp.setFaceMatID theObj theFace (theCurrentMatID + matIDoffset)
					format "%: % %
" theObj.name theFace (theCurrentMatID + matIDoffset)
				)
			)
			default:(
				print "Object cannot be processed"
			)
		)
	)

)

Now please tell me why you have to offset your matIDs?
I never saw MultiSub-Material with 115 sub-materials …

Georg

I made a very heavy scene for an architectural project…

17500 elements – 9 000 000 Polys… etc etc…

For several passes like Mask or Z buf I use an overide material…

An if a palm brack have Material ID1 and Car whells too…

For a mask pass with a pure red shader in the brack, the whells are red too with an overide material…

Idem with an oclusion… if ou have and alpha in a leaf shader with the same ID of a wall…

And I never use Scene state…