XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : diffuse map on/off toggle

01-05-2005, 12:38 PM
is there a script that will toggle on/off the map in the diffuse channel for either the scene/selected objects? i want to disable the map for a render and then turn it on again. all the ones i see on scriptspot are for viewport only.



P.s post duplicated on Discreet forum

01-05-2005, 02:17 PM
-- This script only works on standard materials but that can easily be fixed by adding more

-- checks in the ValidateMaterial function. You will have to make a special case for

-- multi-sub objects

fn ValidateMaterial mat =


if (classof mat == standardMaterial) then

return true

-- add extra checks here


-- If you supply a value to the forceState variable it will force al the materials on or off.

fn ToggleDiffuseMapEnable forceState:undefined =


if selection.count > 0 then

objs = selection as array -- If we have a selection use it


objs = objects as array -- otherwise use all the objects in the scene

-- we must keep track of our materials otherwise we'll keep toggling it on and off if multiple

-- objects use the same material

local matsChecked = #()

-- loop through all the objects, ignoring those without materials

for obj in objs where obj.material != undefined do


-- Check if the material is valid

if (not ValidateMaterial obj.material) then


-- check if the material we're looking at is in our list of checked materials

-- if it is skip it

if (findItem matsChecked obj.material > 0) then


-- toggle the diffuseMapEnable variable in the material

if (forceState == undefined) then

obj.material.diffuseMapEnable = not obj.material.diffuseMapEnable


obj.material.diffuseMapEnable = forceState

-- add the material to the list of checked materials

append matsChecked obj.material



-- Toggle All Diffuse Maps


-- Enable all maps

--ToggleDiffuseMapEnable forceState:true

-- Disable all maps

--ToggleDiffuseMapEnable forceState:false

Sorry if its not properly indented, this WYSIWYG editor doesn't like me very much when it comes to indenting :(

01-05-2005, 02:47 PM
thanks for the reply wahooney - i'll give your code a try

many thanks for your help


CGTalk Moderation
01-20-2006, 09:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.