ScriptSpot

Forum topic · Scripts Wanted

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

By litenin · 2008-05-22

Description

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

 

Comments (6)

martinskinner · 2008-10-24

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! ;)

Martin
www.martinskinner.co.uk

bragibjornson · 2009-06-26

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:

Bldg_01

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

But how would you hide:

Z_Bldg_01_HIDE

if you wanted to use Bldg or 01?

Thanks!

martinskinner · 2008-10-22

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.

Martin
www.martinskinner.co.uk

Attachments

martinskinner · 2008-10-20

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.

Martin

martinskinner · 2008-08-03

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 · 2008-08-03

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