Chaos Scatter > [Scatter] I need help!

Script code to toggle scatters?

(1/2) > >>

aaouviz:
Hi all,

I'm hoping some of you smart people can help me with a quick little bit of code to toggle on/off all of the scene scatters in 3dsmax.

Basically in the same way that it works in the scatter lister, but integrated in to my own existing "make things go faster" toolbar button script that I use.

I'm guessing this is possible, so how might it work?

Thanks in advance for any help!

James Vella:
Not sure what on/off means exactly, but this will toggle the 'enable' button on and off for scatters. Edit: oh right the lister, yes this does that toggle all on/off. Actually this just flips the ones that are on off and the ones that are off on. Ill take another look later should be fairly simple.


--- Code: ---
-- Toggle Chaos Scatter on/off
for i in getClassInstances ChaosScatter target:rootNode do
(
if i.Enable == on then i.Enable = off else i.Enable = on
)


--- End code ---

aaouviz:
Thanks mate. It works well!

However, for the life of me (I often have issues a similar manner) I can't seems to integrate it into my existing script.

The current script looks something like this:


--- Code: ---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


)

--- End code ---

Where/how can I put you code?

Many, many thanks!

James Vella:
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:


--- Code: ---
-- 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
)


--- End code ---

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:


--- Code: ---
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
)
)


--- End code ---

edit: sorry missed a bit, this should work

aaouviz:
Absolute champion!

Got it working

Thanks again mate :)

Navigation

[0] Message Index

[#] Next page

Go to full version