Hiding all the references plans layers

Hiding all the references plans layers

Anonymous
Not applicable
270 Views
2 Replies
Message 1 of 3

Hiding all the references plans layers

Anonymous
Not applicable
Hello, somebody could help me?

I try to develop a maxscript very simple but I don't understand definitely maxscript.

The purpose is to make a simple script which can hide all the layers who's name begin by "ref".
For example an active/inactive button which can show/hide all the "references plans" with similar names as:
"ref layer a"
"ref layer b"
"ref layer c"

For now, I just have this part of code but it's just hiding the layer named "ref" and not all the layers with "ref" in the name:

(
(layerManager.getLayer 0).current = true
rfp= "ref"
for L = 1 to LayerManager.count do
(
layer = (LayerManager.getlayer (L-1))
if layer.name == rfp then layer.ishidden = true
)
)

Thanks for advance for your help!
0 Likes
271 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Maybe this is what'll do teh trick?



-- Toggle layer visibility
fn tglLayer prefix splitChar:" " =
(
local mng = layerManager

for i = 1 to mng.count - 1 where (filterstring (local layer = mng.getLayer i).name splitChar) == prefix do
(
if layer.isHidden then
(
layer.isHidden = False
)
else
(
layer.isHidden = True
)
)
)

/*

tglLayer "ref" splitChar:" " -- where layer name is similar to "ref blah blah"
tglLayer "ref" splitChar:"_" -- where layer name is similar to "ref_blahdi_blah"

splitChar is basically the search string for filterString()
if splitChar is unsupplied it defaults to using " " which is what YOU want it seems =)

*/



BR
MrK

Edit: Made layer var local
0 Likes
Message 3 of 3

Anonymous
Not applicable
WOW !!! What's a GREAT place !
Thanks a lot for this function and for your quickly help !
0 Likes