Script for switching set of layers
Hello
I try to make a little script to switch two set of layers.
example : I have 4 layers with old walls, and a layer where I want to model new walls. I don't want to hide or unhide these particular layers when needed because they are in a long list of other layers.
So my script record a first list of layers : layers of old selected walls ">"
and a second list : layer of my new walls ">"
Then, I can hide or unhide the first "1" or the second "2" list of layer.
BUT, when I write :
----------------------------------------
sel = selection
IsoLayers1 = #()
for i = 1 to sel.count do ( append IsoLayers1 sel[i].layer )
for i in IsoLayers1 do ( i.ishidden = true)
----------------------------------------
I can hide a set of layer.
when I write my script :
----------------------------------------
sel = selection
try(destroydialog RL_Rollout)catch()
rollout RL_Rollout "Layers switch" width:208 height:57
(
button GL1 ">" pos:[5,5] width:30
button GL2 ">" pos:[5,30] width:30
checkbutton PL1 "1" pos:[50,5] width:150
checkbutton PL2 "2" pos:[50,30] width:150 checked:false
on GL1 pressed do
(
sel = selection
IsoLayers1 = #()
for i = 1 to sel.count do ( append IsoLayers1 sel[i].layer )
)
on GL2 pressed do
(
sel = selection
IsoLayers2 = #()
for i = 1 to sel.count do ( append IsoLayers2 sel[i].layer )
)
on PL1 changed theState do
(
if PL1.checked==1 do
(
for i in IsoLayers1 do ( i.ishidden = false)
)
if PL1.checked==0 do
(
for i in IsoLayers2 do ( i.ishidden = true)
)
)
on PL2 changed theState do
(
if PL2.checked==1 do
(
for i in IsoLayers2 do ( i.ishidden = false)
)
if PL2.checked==0 do
(
for i in IsoLayers2 do ( i.ishidden = true)
)
)
)
createdialog RL_Rollout pos:[650,85]
-------------------------------------------------
I get IsoLayers1 : undefined...
Can somebody help ?
Thanks.
Attachment | Size |
---|---|
ls.jpg | 11.09 KB |
Comments
Ok, Miauu. I'll try next time
Ok, Miauu. I'll try next time :-) Thanks
.
you need to define IsoLayers1 inside rollout definition
Ok, thank you soooo much.
Ok, thank you soooo much. Works now :-)
I had to write "local IsoLayers1 = #()"
--------------------------------------------------------------
sel = selection
try(destroydialog RL_Rollout)catch()
rollout RL_Rollout "Layers switch" width:208 height:57
(
button GL1 ">" pos:[5,5] width:30
button GL2 ">" pos:[5,30] width:30
checkbutton PL1 "1" pos:[50,5] width:150 checked:true
checkbutton PL2 "2" pos:[50,30] width:150 checked:true
local IsoLayers1 = #()
local IsoLayers2 = #()
on GL1 pressed do
(
sel = selection
IsoLayers1 = #()
for i = 1 to sel.count do ( append IsoLayers1 sel[i].layer )
)
on GL2 pressed do
(
sel = selection
IsoLayers2 = #()
for i = 1 to sel.count do ( append IsoLayers2 sel[i].layer )
)
on PL1 changed theState do
(
if PL1.checked==1 do
(
for i in IsoLayers1 do ( i.ishidden = false)
)
if PL1.checked==0 do
(
for i in IsoLayers1 do ( i.ishidden = true)
)
)
on PL2 changed theState do
(
if PL2.checked==1 do
(
for i in IsoLayers2 do ( i.ishidden = false)
)
if PL2.checked==0 do
(
for i in IsoLayers2 do ( i.ishidden = true)
)
)
)
createdialog RL_Rollout pos:[650,85]
.
A friendly advice: when you post a code here put it inside
["code"]
-- your code here
["/code"]
without the quotes. This way your code will be formatted properly will be much easier to read. :)
Tools and Scripts for Autodesk 3dsMax