ScriptSpot

Script

LightMod

By netkingZ · 2016-06-22

Version
1.02
Version requirement
3ds Max 2013 and above
Date updated
2016-06-22
Votes
4
Description

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.

Features:
- 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
netkingZ

Attachments

Tags: vRay Light, LightMod, Multiple Light

Comments (8)

fajar · 2016-07-03

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... 

barigazy · 2016-07-04

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.

barigazy · 2016-07-04

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

netkingZ · 2016-07-07

Thanks you @barigazy and @fajar.

zahid hasan · 2016-06-30

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

netkingZ · 2016-07-01

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

tip a little

fajar · 2016-06-23

little bit info


for i in 1 to selection.count do
			(
				if selection.count == 1 then(
					
					if $.baseObject.castShadows == on then(
							$.baseObject.castShadows = off
						)else(
							$.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

netkingZ · 2016-06-27

Your script needs to verify state of castShadow, right?