3 votes
Date Updated: 
Author Name: 

All lights in scene are influenced by parameters of LightMod.
If you selected some lights on scene , all lights selected change based on LightMod parameters.
Usefull with non instanced light.
Script work with vRay Light.

- Cast Shadow
- Double Sided
- Invisible
- No Decay
- SkyLight Portal
- Simple Portal
- Affect Reflections
- Length and width parameters
- Subdivs parameter
- Multiplier parameter

Thanks for your feedback

Version Requirement: 
3ds Max 2013 and above
lightmod_v1.02.ms6.32 KB


Comment viewing options

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

Thanks you @barigazy and

Thanks you @barigazy and @fajar.

barigazy's picture


Anyway... it is better to continue discussion about the optimization of code in the forum section. This is not right place.

Edit: toggle code correction

node.affect_reflections = not node.affect_reflections


barigazy's picture


This tool can be simplified much more because supports only one type of lite (VrayLight). So my suggestion is:
#1 when you want to toggle some parameters u can use

node.affect_reflections == not node.affect_reflections

#2 Don't use "$" sign. It's better to use some variable like node, object, light, modifier, camera etc. because are predefined.
#3 To change all VRayLight Params you can use one function to control all values.
#4 If you planing to make changes on selected lights only then you can use this function to collect all unique lights from current selection ei. all copies of the first instance light

-- first we need some filter function. You can expand this later if you want to support more light types
fn filterVRLight light = isKindOf light VRayLight and not isKindOf light TargetObject
-- with this fn you will collect only unique light.
-- argument "func" will use filter fn
fn collectUniqueNodes objs func:filterVRLight = if objs.count != 0 do
	objs = for o in objs where func o collect o
	local uniqNodes = #(), allHandles = #{}, getObjIns = InstanceMgr.GetInstances 
	for o in objs do append allHandles (getHandleByAnim o)
	while not allHandles.isEmpty do
		obj = GetAnimByHandle (for i in allHandles do exit with i)
		getObjIns obj &firstOnly ; append uniqNodes firstOnly[firstOnly.count]
		for o in firstOnly do allHandles[(getHandleByAnim o)] = off
	) ; uniqNodes
-- and use it like this
collectUniqueNodes selection

After collecting all supported unique lights everything else is a piece of cake ;)
You not need to check every parameter ei. property whether or not exists.


fajar's picture

Indeed.... But thats only the

Indeed.... But thats only the tip of it tho... Here is how to extend it a little....

Fn mdlightstate sel:true prop:#on val:true =
( local nodes= if sel==true then (nodes=(for i in selection where iskindof light collect i) else nodes=lights
For i in nodes where (getproperty i. Baseobject prop!= undefined do setproperty i.baseobject prop val

In collaboration with your script.... Its in button pressed

On affectreflectionbutton pressed do
Mdlightstate sel:true prop:#affect_reflections val:on -- or off
On nodecaybutton pressed do
Mdlightstate sel:true prop:#nodecay val:true
-- etc... Sel=true,  performed on selection light only,  false on all light... 
netkingZ's picture

This script work only lights

This script work only lights selected.
What specific type do you whant?

zahidhasan's picture

Hi, can you bring more

Hi, can you bring more options like only selection will be effected or a specific type.
Thanks for your script.

netkingZ's picture

Your script needs to verify

Your script needs to verify state of castShadow, right?

fajar's picture

tip a little

little bit info

for i in 1 to selection.count do
				if selection.count == 1 then(
					if $.baseObject.castShadows == on then(
							$.baseObject.castShadows = off
							$.baseObject.castShadows = on

you should correct this iteration tho .....
for an instance you could use

fn castShadowTurn state:off =
for i in selection where ((iskindOf i light) and (getProperty i.baseObject #castShadows)!=undefined) do setProperty i #castShadows state
--maybe like that...I dont have max on my hand tho

Comment viewing options

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