I present to you, the longer version:
if selection.count > 0 then
(
for o in selection do
(
objClass = (superClassOf o)
if objClass == light do
(
if (isProperty o #on) == true do
(
enabled = o.on
if enabled == true then o.on = false
else o.on = true
)
)
)
deselect selection
)
else messageBox "Nothing selected!"
Extended super long version, now supporting all Vray Light types…
(
local CurSel = GetCurrentSelection()
if CurSel.count > 0 then
(
for CheckNode in CurSel do
(
local objClass = (superClassOf CheckNode)
if objClass == light do
(
case of
(
(isProperty CheckNode #on):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.on = false
)
else
(
CheckNode.on = true
)
)
(isProperty CheckNode #enabled):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.enabled = false
)
else
(
CheckNode.enabled = true
)
)
)
)
)
deselect selection
)
else messageBox "Nothing selected!"
)
Weeeeellll you might as well add UNDO to it…
(
local CurSel = GetCurrentSelection()
if CurSel.count > 0 then
(
UNDO "Switch Light State" ON
(
for CheckNode in CurSel do
(
local objClass = (superClassOf CheckNode)
if objClass == light do
(
case of
(
(isProperty CheckNode #on):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.on = false
)
else
(
CheckNode.on = true
)
)
(isProperty CheckNode #enabled):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.enabled = false
)
else
(
CheckNode.enabled = true
)
)
)
)
)
)
deselect selection
)
else messageBox "Nothing selected!"
)
What a collaboration! Added with redraw off and some unnecessary code.
(
curSel = #()
for obj in selection do
(
append curSel obj
)
if CurSel.count > 0 then
(
UNDO "Switch Light State" ON
(
with redraw off
(
for CheckNode in CurSel do
(
local objClass = (superClassOf CheckNode)
if objClass == light do
(
case of
(
(isProperty CheckNode #on):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.on = false
)
else
(
CheckNode.on = true
)
)
(isProperty CheckNode #enabled):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.enabled = false
)
else
(
CheckNode.enabled = true
)
)
)
)
)
)
)
for obj in curSel do
(
deselect obj
)
)
else messageBox "Nothing selected!"
)
LostDragon you should use this script instead. The other small ones are little babies, this one packs a punch!
ooooo… The undo WITH a descriptor…interesting…
But my undo menu still says “Undo MaxScript”
Nice… Why do one loop when you can do three… We may need a nested solution soon…
How about 3 more lines ?
(
curSel = #()
for i = 1 to selection.count do
(
obj = selection[i]
append curSel obj
)
if CurSel.count > 0 then
(
UNDO "Switch Light State" ON
(
with redraw off
(
for i = 1 to CurSel.count do
(
CheckNode = CurSel[i]
local objClass = (superClassOf CheckNode)
if objClass == light do
(
case of
(
(isProperty CheckNode #on):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.on = false
)
else
(
CheckNode.on = true
)
)
(isProperty CheckNode #enabled):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.enabled = false
)
else
(
CheckNode.enabled = true
)
)
)
)
)
)
)
for i = 1 to curSel.count do
(
obj = curSel[i]
deselect obj
)
)
else messageBox "Nothing selected!"
)
Just need someone to add a midi version of The Smiths ‘There Is A Light That Never Goes Out’, that plays everytime the script runs and we should be there.
Download KClasses and change the assembly to the correct path you’ve unziped
(
dotnet.loadAssembly @"C:\KClasses.dll"
local KPlayer = dotnetobject "KClasses.dnMIDI"
rollout plMIDI "You can DO IT!"
(
button btnStop "Stop playing!"
on btnStop pressed do
(
KPlayer.StopMIDI()
destroyDialog plMIDI
)
)
curSel = #()
for i = 1 to selection.count do
(
obj = selection[i]
append curSel obj
)
if CurSel.count > 0 then
(
UNDO "Switch Light State" ON
(
with redraw off
(
for i = 1 to CurSel.count do
(
CheckNode = CurSel[i]
local objClass = (superClassOf CheckNode)
if objClass == light do
(
case of
(
(isProperty CheckNode #on):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.on = false
)
else
(
CheckNode.on = true
)
)
(isProperty CheckNode #enabled):
(
local enabled = CheckNode.enabled
if enabled == true then
(
CheckNode.enabled = false
)
else
(
CheckNode.enabled = true
)
)
)
)
)
)
)
for i = 1 to curSel.count do
(
obj = curSel[i]
deselect obj
)
createdialog plMIDI
KPlayer.PlayMIDI "C:\smiths_thereisalight.mid"
)
else messageBox "Nothing selected!"
)
Maxscript help doesnt have anything about
Llister
how can enable it?
thanks wizards!