Notifications
Clear all

[Closed] MaxScript Change materials via slider

Hello

I was wondering is there a way to change materials (50+) via slider in MaxScript? Assuming that Compact material editor has max 24 free slots to cycle, can it be done in Slate material editor or in material library? (in my case all of the materials are “standard”) I made a simple script to test it out in Compact ME just to specify my problem a bit more.
What I want my script to do is to choose mesh by name (filtered for just geometry) by Button and printed name of that mesh in edittext below button to check chosen and use spinner to cycle materials (in any way) to that mesh. There is a edittext box under slider that would print material name just to check. That should be automated process of cycle through materials >select object – select material – assign material to selection – show shaded material in viewport< –every specific material is standard and have different diffuse bitmap and self illumination set to 100–

I would appreciate help with the code or an example similar to this if someone is familiar to this kind of issue. Thanks in advance.
Script is below.

try (destroyDialog TestMaterials) catch ()

Rollout TestMaterials "Materials" width:120
(
	global tempMaterial = "Material_0"
	
	spinner spMaterial "Material" type:#integer range:[0,50,0] align:#left width:100 height:20
	edittext nmMaterial text:(tempMaterial as string) readOnly:true align:#left offset:[0,-6] width:100 height:18
	label lbSel "------------------"
	button bnSelGeom "Select Geometry" align:#left height:30 width:97
	edittext nmGeom "" readonly:true align:#left height:50 width:97		

	
	
	
	on bnSelGeom pressed do
		(
			chosenMesh = selectByName title:"Choose Mesh to test material change" showHidden:true
			--nmGeometry.text = chosenMesh.name  --<<<this should be printed selected mesh names
		)
	
	on spMaterial changed mtlvar do
			(
				mtlvar = spMaterial.value type:#integer
				currentMaterial = getMEditMaterial (mtlvar as string)
				nmMaterial.text = currentMaterial.name
			)
	
	
	)
	createDialog TestMaterials