Notifications
Clear all

[Closed] Setting All Scene Material Maps Amounts

I’m new to both 3ds max & MAXScript and I’m having trouble with creating a script to set all of the Material Map Amounts on all materials in a scene back to the default Map Amount values.

– I want to step through each Material in the scene using a loop.

– Change the Maps Amount for each material to the following:
meditMaterials[1].ambientMapAmount = 100
meditMaterials[1].diffuseMapAmount = 100
meditMaterials[1].specularMapAmount = 100
meditMaterials[1].specularLevelMapAmount = 100
meditMaterials[1].glossinessMapAmount = 100
meditMaterials[1].selfillumMapAmount = 100
meditMaterials[1].opacityMapAmount = 100
meditMaterials[1].filterMapAmount = 100
meditMaterials[1].bumpMapAmount = 30
meditMaterials[1].reflectionMapAmount = 100
meditMaterials[1].refractionMapAmount = 100
meditMaterials[1].displacementMapAmount = 100

– Save the file
max file save

– Open File Command to get the next file.
max file open

– END OF SCRIPT

What is confusing me is the meditMaterials[#] IDs. I need to change all of the materials in the scene, not just using one ID.

Thanks for any help that can be provided.

3 Replies

The meditMaterials is used to access the 24 materials in the Material Editor. The following code will change all standard materials in the scene:

(
	-- get all instances of 'standardmaterial' used in the scene
	-- and the material editor
	standardMats = getclassinstances standardmaterial
	
	-- reset all these materials to their standard values
	for m in standardMats do
	(
		m.ambientMapAmount = 100
		m.diffuseMapAmount = 100
		m.specularMapAmount = 100
		m.specularLevelMapAmount = 100
		m.glossinessMapAmount = 100
		m.selfillumMapAmount = 100
		m.opacityMapAmount = 100
		m.filterMapAmount = 100
		m.bumpMapAmount = 30
		m.reflectionMapAmount = 100
		m.refractionMapAmount = 100
		m.displacementMapAmount = 100
	)
	
	-- display results in listener
	format "% standard materials modified.
" standardMats.count
)

Cheers,
Martijn

Thank You for the code. Now I have a new question.

I just noticed that the textures are not appearing in the Viewports, unless I press the “Show Texture Map in Viewport” icon for every Diffuse Map for every Material and Sub Materials.

Can I…

A.) Add a line in the 3dsmax.ini file to set that it is always on by default?
-or-
B.) Add to the current loop for all materials&sub-materials turn on the “Show Texture Map in Viewport” for Diffuse Map.

-- turn on/off diffusemap in viewport?
showDiffuse = true

-- get all instances of 'standardmaterial' used in the scene
-- and the material editor
standardMats = getclassinstances standardmaterial

-- reset all these materials to their standard values
for m in standardMats do
(
	m.ambientMapAmount = 100
	m.diffuseMapAmount = 100
	m.specularMapAmount = 100
	m.specularLevelMapAmount = 100
	m.glossinessMapAmount = 100
	m.selfillumMapAmount = 100
	m.opacityMapAmount = 100
	m.filterMapAmount = 100
	m.bumpMapAmount = 30
	m.reflectionMapAmount = 100
	m.refractionMapAmount = 100
	m.displacementMapAmount = 100
	
	-- turn on/off diffusemap in viewport
	if m.diffusemap != undefined then
		showtexturemap m m.diffusemap showDiffuse
)

-- display results in listener
format "% standard materials processed.
" standardMats.count

Change the showDiffuse variable at the top of the script to false to hide the diffusemaps in the viewports.

  • Martijn