[REQ] Add hidden layer

Hi! I really missing a simple command that would create a hidden
layer (it MUST stay hidden in every scene state no matter it's existing or it will be created lately).
This script would be EXTREMELY helpful in setting up the compositions to get rendered.
There's plugin in Sketchup made by Jim and it's pretty much what
I want (but in MAX):
http://sketchuptips.blogspot.com/2007/08/add-hidden-layer.html
Ideas?
Thanks
R
.

Comments

Comment viewing options

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

Thank you Anubis once again.

Thank you Anubis once again. Please feel free to stop developing the thing
you started due to commercial considerations, never mind (though I beleive
if it could be done it'd drop a couple of cents from the community, 'cause it's really useful)
well it worked for me @last. but may be because I don't explain myself clear the it went in the wrong direction a bit. your newest script hides the only existing layer upon the render starts and that's all.
--
The script was meant to
CREATE LAYER that:
1.gets turned off upon creating many new scene states or restoring
the existing ones.
2.stays 'on' (in the scene state)only if I manually turn it 'on' and then update this particular scene state.
The user need to CREATE MANY layers like this, not modifying the only existing one (that's the point of the script,- to manage the layer mess
upon creating many sc.states).
--
Anyway REALLY thank you for attention, though it's a pity it didn't grow to what it was intended to.

Anubis's picture

start posting on top

Well, am sure you run the first .ms file as intended, but what about the rest code i post so far? Ok, never mind. So, you expect some more complex script. The current script do not automatize anything related to scene states or presets, nor yet create something (layers for ex.). So... I attach the script (Hide_Layer_in_preRender.ms) and just follow this instructions:

1) Put the script in your Max/Scripts/Startup folder.
2) In your scene(s) create (your self) layer with name "HiddenLayer". Its a readable name that remind it purpose. Changing the name all the time sounds very unmanaged to me, its your choice and if you do that then edit the name of the layer into the script as well (1st line) and re-execute the script.
3) Move the objects you like to hide to that layer (HiddenLayer) and made your scene state.

As you see, the step 2 and 3 are not a part of this script. The script itself will only hide the layer named "HiddenLayer" before rendering begin and only if that layer exist of course.

I think thats enough free help from me ;-)

Regards,
Anubis

AttachmentSize
hide_layer_in_prerender.ms 276 bytes

my recent MAXScripts RSS (archive here)

1rv's picture

first off thank your

first off thank your participation!
I tried it and it does.. nothing!
What I expect is after running the script to receive a small window that asking for a new hidd. layer name. Then it should create it. It should be invisible
by default on every existing\new born scene state. And only if I manually turn it
ON and then update the layer state it will keep stayin' 'ON'.
That's my vision :)

Anubis's picture

the script works!

well, more details are welcome ;)

So, I presume the name of the 'hidden' layer should be fixed and I used the name "HiddenLayer" and as you say you will setup the name just once, then why you need a dialog for? -just edit the script.

Ah, and by hidden all we understand it state (see the picture), or did you mean something else?

P.S. - Actually, the script will work fine when you load or merge scenes, but creation of new layer goes with some default auto generated name and unfortunately the renaming of layers cannot be handled.

Ok, to not leave you disappointed, lets think logical, the main point of the script you ask is to not forget to hide concrete layer when render, right? So instead of monitoring so many events, all that you need is only one pre-render callback script.

HLName = "HiddenLayer" -- change to what you like
 
Call = "theLyr = LayerManager.getLayerFromName HLName;" +
	"if theLyr != undefined do theLyr.ishidden = true"
 
callbacks.removeScripts #preRender id:#cbHiddenLayer
callbacks.addScript #preRender Call id:#cbHiddenLayer

cheers

AttachmentSize
hidden_layer.png 5.61 KB

my recent MAXScripts RSS (archive here)

1rv's picture

The main goal of the script

The main goal of the script is to MANAGE the archviz entourage (people,cars,trees)and the light sourses depending on camera\scene state.
For example the palm tree+ a couple of people+ 2 cars look good and on their RIGHT
places from the camera #1. But from the camera #2 they might hide the main object
(i.e. building)AND I need a new sun from the opposite direction. I'd instance the entourage\ lite sourses to Your hidd. layer and place my stuff in better places (better for cam.#2). The whole point is that cam#1 entourage set, cam#2 entourage set, cam#N entourage set normally would be hidden
in all other views\scene states to prevent the mess
. To set up the file without this script is a big pain in the @ss.
Sorry if my input was not 100% clear.
P.S. I tried the script once again- NADA (tested on max2010 x64\max2009 x32) What do I do wrong? What's the procedure?

Anubis's picture

I use the Max Event Callbacks

I use the Max Event Callbacks system and the script works (Max2009), but it s'd work in 2010 and so on and s'd work for you as well, now i just made some guess what you did wrong.
Did you test the last preRender callback i post above? Make sure the name in variable HLName is the actual name of your layer.

P.S. - Ok, here is a simple test to as a proof. You can do this staffs and without script:

--// test scene setup ------------
resetMaxFile() -- reset the scene
b = box() -- create a box
t = teapot() -- create a teapot
-- create new layer named "Special"
layer = LayerManager.newLayerFromName "Special"
-- add the teapot to that Special layer
layer.addNode t

Well, this is just to have some test scene, and here is the callback script:

--// the callback setup ----------
HLName = "Special" -- define the layer name to hide
-- define the expresion to be executed in preRender event
Call = "theLyr = LayerManager.getLayerFromName HLName;" +
	"if theLyr != undefined do theLyr.ishidden = true"
-- standard script procedure - removing old callbacks before adding new
callbacks.removeScripts #preRender id:#cbHiddenLayer
-- register our new preRender callback
callbacks.addScript #preRender Call id:#cbHiddenLayer

Now press Render.
The result (see the pucture)

AttachmentSize
hidelayer_prerender_preview.png 15.91 KB

my recent MAXScripts RSS (archive here)

1rv's picture

Sorry but I'm afraid I

Sorry but I'm afraid I understand nothing of this callbacks-nhlname poetry :).
I'm just a simple architect\viz monkey. I tested it on 3 diffrent PCs and it did not work. Could you describe the procedure and the results plz?

Anubis's picture

?...

So, you made an example scene with box and teapot, create layer named "Special", moved the teapot to that layer, execute the callback part and nothing happens then render!?... thats impossible :(

The result i shows at the attached picture above - and it is - the layer "Special" is hidden and the teapot inside too, so only the box is rendered.

If some code explanation will feel you better, here is some notes.

The callbacks shema is simple:

callbacks.addScript \ -- the func. that register new callback
	#theEventTypeName \ -- its 1st argument (in your case #preRender)
	"the_function_or_expression_to_execute" \ -- 2nd argument (in the example code its an expression stored in variable Call)
	id:#theIDName -- this need to can unregister (if/when needs)
-- this function has and other optional arguments that are not interesting right now

The code... HLName = "Special" is just the name of the layer assigned to variable to can you find and modify it easy. And the actual script that is fired is 2 lines:
theLyr = LayerManager.getLayerFromName HLName - here the script try to get the layer by name (the name is passed by variable HLName). Or exact the same with direct string:
theLyr = LayerManager.getLayerFromName "Special"
and the 2nd line is executed if the layer named (in this example - "Special") exist:
if theLyr != undefined do theLyr.ishidden = true

Well, it's works as it should for me and after all if that not helps to you then pay someone for QA.

Regards,
Anubis

P.S. - and finally, just to ask - how exactly you run/execute all the code i posted here? This is my last assumption :) Where did you paste the code? Into the Listener or into the Editor (MaxScript/New Script)? If you execute it line-by-line then use Numpad Enter key (not the bigger one Enter). If you run it from the Editor then just hit CTRL+E. And more simple cant be - save the code to text file with .MS extension (for eg "script.ms") and then just drag-n-drop the file to your Max viewport.

my recent MAXScripts RSS (archive here)

1rv's picture

I put hiddenlayer.ms into the

I put hiddenlayer.ms into the scripts folder. Then via 'Run script' I execute it.
As result I expect the creation of very special layer (hidden in all present\to be
created scene states. AND ONLY IF I'd turn it on and update the scene state it'd continue to be visible on this sc.state only!).Are my steps logical 'till now? But nothing happened after I run it.

Anubis's picture

...

i'll post on top of the page 'cause the forum shift the replies too much.

my recent MAXScripts RSS (archive here)

Comment viewing options

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