I try to make a simple script to hide part of layers.

Hello, I try to develop a maxscript very simple but I don't understand how it can work!

The purpose is to make a simple script which can hide all the layers who's name begin by "ref".

For now, I just have this part of code and it seems that it's not a good beginning!


(layerManager.getLayer 0).current = true

hide_layers=layerManager.getLayerFromName "ref"

hide_layers.isHidden = true


Thanks for yours responses 



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
martinskinner's picture

Hi Brave, Glad i could help.

Hi Brave, Glad i could help. Great to hear you've come up with something that works. Often that's the whole trick to scripting;- Having a task/project that demands it, and then the drive to work through to the answer(s). Well done on reaching the goal, and Happy Scripting from here on in! :)

I'm lining myself up to take a look at C++.I'm pretty new to programming having only ventured into MaxScript after working with 3dsMax for years doing Architectural Visuals; all those pre-lim block models made me write Block Model ToolBox 4.6 to speed up my workflow. Good to know that others are using it now too.

I'm hoping that learning a little C++ might aid my MaxScript (though i know they're different), and i'm sure it'll be interesting to delve into. Simple games, here we come! ;)


bragibjornson's picture

I have a question on

I have a question on this:

Ive been looking at the script you guys posted, and can hide/unhide layers based on what the layer starts and ends with - even if its text.

But I can't figure out how to hide/unhide based on a parameter thats actually "inside" the layer.

For example:

I can hide/unhide layers like:


by using either "Bldg*" or "*01"

But how would you hide:


if you wanted to use Bldg or 01?


martinskinner's picture

Hi Brave, The attached

Hi Brave,

The attached should do the job ;)

It looks for numbering in your layering system and then only shows the Level you have picked from the drop down list whilst leaving default 0 layer on.

Hope it's of help.


Level_shower.ms 7.92 KB
martinskinner's picture

Hi Braven, I think the tool

Hi Braven,
I think the tool Scene States already found within 3dsMax might do the trick. No scripting needed ;)

Have a look, see if it does the trick.


martinskinner's picture

Here's the answer including

Here's the answer including comments, just cut and paste.

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 "ref"         -- 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
	 else x.on = true                   -- the layer x is off, then turn it on. A toggle on/off really                      
	)                                   -- end if
)                                            -- end loop
/* This script can be altered to turn layers with names begining
in something other then "ref" simply by altering the line;
<location = findString test "ref"> within the loop, to the string
required to search for.*/
-- Written by Martin Skinner
-- www.martinskinner.co.uk
martinskinner's picture

Hi, Are you still struggling

Are you still struggling with this script?
I'd be happy to have look at sorting it.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.