-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddSelectedLightsToLightSelect.ms
More file actions
63 lines (56 loc) · 2.21 KB
/
AddSelectedLightsToLightSelect.ms
File metadata and controls
63 lines (56 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
macroScript AddLightsToLightSelect
category:"ilya_s Scripts"
tooltip:"AddLightsToLS"
buttontext:"AddLightsToLS"
(
-- Not the best way to do this
-- Basically gets the "Enable Filter" checkbox and gets the next element which is the field with the name of the selected render element
-- from there we find the render element object with that name
fn getSelectedRendEle =
(
local result = undefined
local hWnd = for i in (windows.getChildrenHWND (windows.getDesktopHWND())) where matchpattern i[5] pattern:"Render Setup*" do (exit with i[1])
if hWnd then
(
local renderWindChild = windows.getChildrenHWND hWnd
local index = for i=1 to renderWindChild.count where matchpattern renderWindChild[i][5] pattern:"Enable Filtering*" do (exit with i)
local rendEleName = renderWindChild[index+1][5]
if rendEleName != "" then
(
local re = MaxOps.GetCurRenderElementMgr()
local rendEleObj = for i = 0 to re.NumRenderElements() - 1 where (re.GetRenderElement i).elementName == rendEleName do (exit with re.GetRenderElement i)
if rendEleObj != undefined and classof rendEleObj == VRayLightSelect then result = rendEleObj
)
)
result
)
if (tabbedDialogs.getPageTitle #render (tabbedDialogs.getCurrentPage #render) == "Render Elements") then
(
local rendEleObj = getSelectedRendEle()
if rendEleObj != undefined then
(
if rendEleObj.lights.count > 0 then
(
local qb = yesNoCancelBox "Lights found in the selected renderer element.\nAppend?\n\n[Yes] - Append selected to list\n[No] - Overwrite list"
if qb == #yes then
(
local arr = makeUniqueArray (join (rendEleObj.lights as array) (for o in selection as array where superclassof o == light collect o ))
rendEleObj.lights = arr
)
else if qb == #no then (rendEleObj.lights = for o in selection as array where superclassof o == light collect o)
)
else
(
rendEleObj.lights = for o in selection as array where superclassof o == light collect o
)
)
else
(
messageBox "Select a VRayLightSelect render element to add lights to"
)
)
else
(
messageBox "Open the Render Setup dialog and select a VRayLightSelect render element"
)
)