Chaos Corona Forum
Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: Alex Abarca on 2024-08-21, 23:11:48
-
Hi All,
Does anyone have a script that looks in the scene's material for CoronaSelect nodes and the toggles the CoronaSelect from 0 to 1?
I have decals that needs to switch from ON and OFF in the scene.
Thank you!
-
You could do something like this:
(
-- Collect Corona Materials from Slate Material Editor selection
local selected_materials = #()
if (sme.getview sme.activeView) != undefined then
(
selected_nodes = (sme.getview sme.activeView).GetSelectedNodes()
if selected_nodes.count != 0 then
(
for node in selected_nodes do
(
if (superclassof node.reference == material) then
(
if classof node.reference == CoronaPhysicalMtl or
classof node.reference == CoronaLegacyMtl then
(
append selected_materials node.reference
)
)
)
)
)
-- Toggle Corona Select 0 or 1 (does not support more than 0 or 1)
for i in selected_materials do
(
for cSelect in (getClassInstances CoronaSelect target:i) do
(
if cSelect.selected == 0 then
(
cSelect.selected = 1
)
else
(
cSelect.selected = 0
)
)
)
)
Notes:
- Supports 0 or 1, if you need additional "map count" then you would have to change the script.
- Works on selected material in Slate Editor (not selected objects or child nodes in the Slate Editor).
- If you have 2 materials sharing the one Corona Select node only pick one of the materials (in your screenshot for example).
-
Also if you just want to do it scene wide without having to select materials you could use this instead:
for cSelect in getClassInstances CoronaSelect do
(
if cSelect.selected == 0 then
(
cSelect.selected = 1
)
else
(
cSelect.selected = 0
)
)
-
Thanks, James! I have to say, both scripts are pretty nifty, and I can see the use cases for each. However, in my case, I need to remove logos from library objects that are scattered across the scene, and this is something I have to deal with regularly. Given my situation, I prefer the second script. Appreciate the help!
-
You're welcome! Yes feel free to use which is best for your situation. I figured someone might also want the first script so I kept both here in case.
It wouldn't be hard to a toggle for one with 100+ "map count"(s) either but I only spent 30 seconds on each so that will do for now lol.
Also just be aware its just a toggle, so this is assuming you keep your workflow consistent, if you somewhere along the line decide to flip 0 with 1 in your CoronaSelect then you will encounter unexpected results.