Author Topic: Adding show materials/texture in the Corona Toolbar  (Read 2662 times)

2018-04-04, 09:24:09

JoachimArt

  • Active Users
  • **
  • Posts: 217
    • View Profile
    • JoachimArt
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. 

2018-04-05, 21:12:01
Reply #1

Alina Hramyka

  • Active Users
  • **
  • Posts: 37
    • View Profile

2018-04-06, 19:18:56
Reply #2

Frood

  • Active Users
  • **
  • Posts: 1922
    • View Profile
    • Rakete GmbH
Not sure If I get it correctly but try this edit: non error proof quickie:

- paste the following line into the maxscript listener:

Code: [Select]
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


« Last Edit: 2018-04-06, 19:34:47 by Frood »
Never underestimate the power of a well placed level one spell.

2018-04-10, 20:49:12
Reply #3

Frood

  • Active Users
  • **
  • Posts: 1922
    • View Profile
    • Rakete GmbH
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)

I wish it was a way to add a keyboard shortcut to turn it on/off on the selected material

Code: [Select]
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

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.

Since Martin has his precious Converter well documented, 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:

Code: [Select]
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:

Code: [Select]
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



Never underestimate the power of a well placed level one spell.

2018-04-18, 15:20:44
Reply #4

JoachimArt

  • Active Users
  • **
  • Posts: 217
    • View Profile
    • JoachimArt
Thank you for this! :) 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.