This one does more of a similar job to toggle all on/off, the first one I posted just flips it. So this should be better to use:
-- Find if Scatter is on/off
for i in getClassInstances ChaosScatter target:rootNode do
(
if i.Enable == on then global cs_enabled = true else cs_enabled = false
)
-- Toggle Chaos Scatter on/off
for i in getClassInstances ChaosScatter target:rootNode do
(
if cs_enabled == true then i.enable = off else i.enable = on
)
Regarding your code, you have an open parenthesis at the bottom, so thats either a mistake or you missed something above. But it should look something like this:
macroscript ToggleScattersOff
category: "AAScripts"
buttonText: "Sk Off"
tooltip: "ToggleScatters"
Icon:#("AAScatters",1)
(
for i = 0 to (layermanager.count - 1) do -- loops through all the layers in the scene
(
x = layermanager.getlayer i -- gets layer
test = x.name as string -- applies the name of layer to test
location = findString test "10_" -- finds "ref" in layer name, output 1 if present
if location == 1 do -- if ref is present in the layer name at the begining, 1 then
(
if x.on == true then x.on = false -- the layer x is on, then turn it off
-- the layer x is off, then turn it on. A toggle on/off really
) -- end if
) -- end loop
-- Find if Scatter is on/off
for i in getClassInstances ChaosScatter target:rootNode do
(
if i.Enable == on then global cs_enabled = true else cs_enabled = false
)
-- Toggle Chaos Scatter on/off
for i in getClassInstances ChaosScatter target:rootNode do
(
if cs_enabled == true then i.enable = off else i.enable = on
)
)
edit: sorry missed a bit, this should work