Adding show materials/texture in the Corona Toolbar

For workflow purposes I always felt the show shaded materials/texture button in the Material Editor is too tedious to use (especially with a ton of materials). I wish it was a way to add a keyboard shortcut to turn it on/off on the selected material, but I haven’t found it. All the scripts I tried doesn’t work with Corona, except in the Corona Converter script, its possible to turn on/off for the selected objects…which is better than what Max has to offer. But this option is so useful IMO that I wish it was a button or shortcut available instantly. So, personally I would have loved for it to be part of the Corona Toolbar which comes with the next release.

+100

Not sure If I get it correctly but try this edit: non error proof quickie:

  • paste the following line into the maxscript listener:

for obj in $selection do (obj.material.showInViewport= not obj.material.showInViewport)

  • select the line

  • drag the selection to any toolbar (yes, Corona toolbar would also do, but if you already have a personal toolbar it would be a better place)

  • right click on your new button and select “Edit Button Appearance” to choose some icon and set a tooltip

Good Luck

Just had the chance to revisit this, there are already two options.

A)Toggle script (toggles “showInviewport” property like the button in the material editor)

macroScript Toggle_material_viewport_display
	category:"DragAndDrop"
	toolTip:"Toggle material viewport display on/off"
(

on execute do (
	printInf=true
	mats=#()
	for obj in $selection do (
		if printInf then format "%" obj.name
		if (obj.material !=undefined) then (
			if printInf do format "\t%\t%\n" obj.material.name (classOf(obj.material) as string)
			if (classOf(obj.material)==Multimaterial) then (	
 				for msmat in obj.material do (
					if (msmat!=undefined) do (appendIfUnique mats msmat)
				)
 			)
 			else (
 				appendIfUnique mats obj.material
 			)
		)
		else (
			if printInf then format "\n"
		)
	)

	for i in (mats) do (
		i.showInViewport=not i.showInViewport
	)
)

)

This is the replacement for that somehow provoking script from the previous post. It prints some info (object | material name | material class) into the listener for testing purpose. I found that quite useful. Set printInf=false to disable prints. In multisub materials every submaterial just gets toggled without recursion. I’m not sure about the best option here - depends on taste also…

B) Call CoronaConverter functions externally

Since Martin has his precious (http://www.racoon-artworks.de/CoronaConverter/CoronaConverter.html) well (http://www.racoon-artworks.de/CoronaConverter/mxsDocumentation.html), we can use those mentioned CoronaConverter buttons directly in any keyboard shortcut or custom button:

Using Corona Converter: Show maps in VP (selected obj.) on:

macroScript CoronaConverterShowMapsInViewportOn
category:"DragAndDrop"
toolTip:"ShowMapsInViewport on (selection)"

(
	::CoronaConverterSuppressGui = true
	::CoronaConverter
	if (CoronaConverter==undefined) do (
		local scriptDirectory = (GetDir #scripts) + "\\CoronaRenderer"
		local scriptFiles = getfiles (scriptDirectory + "\\CoronaConverter_v*.ms")
		if scriptFiles.count > 0 then (
			sort scriptFiles
			local latestFile = scriptFiles[scriptFiles.count]
			filein latestFile
		) else (
			messageBox (@"No CoronaConverter script file found in " + scriptDirectory) title:"Error"
		)
	)
	CoronaConverter.converterTools.showMapsInVP true selected:true
	::CoronaConverterSuppressGui = false
)

Using Corona Converter: Show maps in VP (selected obj.) off:

macroScript CoronaConverterShowMapsInViewportOff
category:"DragAndDrop"
toolTip:"ShowMapsInViewport off (selection)"

(
	::CoronaConverterSuppressGui = true
	::CoronaConverter
	if (CoronaConverter==undefined) do (
		local scriptDirectory = (GetDir #scripts) + "\\CoronaRenderer"
		local scriptFiles = getfiles (scriptDirectory + "\\CoronaConverter_v*.ms")
		if scriptFiles.count > 0 then (
			sort scriptFiles
			local latestFile = scriptFiles[scriptFiles.count]
			filein latestFile
		) else (
			messageBox (@"No CoronaConverter script file found in " + scriptDirectory) title:"Error"
		)
	)
	CoronaConverter.converterTools.showMapsInVP false selected:true
	::CoronaConverterSuppressGui = false
)

Drawback is that you need to create two buttons/shortcuts - but you will get 1:1 the functionality of the lastest installed CoronaConverter (used the code from the Corona init script to file it in).

Good Luck

Thank you for this! :smiley: I will test it out.
I still think it would be a nice feature to the corona toolbar. I dont understand why Autodesk hasn’t made it possible to turn on/off view in viewport on all selected materials in the material editor. But since all the other scripts I tried that do this only works with standard shader I would have loved for it to be on the corona toolbar.