SCript to change material "show in viewport"

Hi all and happy new year!

Somthing tells me this 'could' be easy...

I am trying to make a script that will automatically change every material that is in the current scene so they do NOT 'show standard map in viewport'. Does anyone have an idea on the code for this?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Garp's picture

Some texture maps can have

Some texture maps can have nested texture maps in them. But it would be tedious to go through all of them turning them off.
A workaround is to force the material to on, then off.

fn offShowInViewport theMat =
(
	if (numSubMtls = getNumSubMtls theMat) != 0 then
		for i = 1 to numSubMtls do
			offShowInViewport (getSubMtl theMat i)
	else
	(
		theMat.showInViewport = true
		theMat.showInViewport = false
	)
)
 
for m in sceneMaterials do offShowInViewport m
windrock's picture

Thanks alot. The code below

Thanks alot. The code below is working except for one problem. If there is no diffusemap in the slot, the script halts. Would you know how to add a check to see if a diffuse map exists before proceeding?

(
for object in selection do
if (classOf object.material == Vraymtl) then
(
object.material.showInViewport = off
showTextureMap object.material object.material.diffusemap off
)
else if (classOf object.material == Multimaterial) then
(
for b = 1 to b = object.material.numsubs do
(
if (classOf object.material.materialList[b] == Vraymtl) then
(
object.material.showInViewport = off
)
)
)
updateToolbarButtons()
)

hedphelym's picture

here's a script. source :

here's a script.
source : http://www.polycount.com/forum/showthread.php?t=76143

for object in selection do

if (classOf object.material == Standard) then
(
object.material.showInViewport = off

)
else if (classOf object.material == Multimaterial) then
(
for b = 1 to b = object.material.numsubs do
(
if (classOf object.material.materialList[b] == Standard) then
(
object.material.showInViewport = off

)
)
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.