Store visibility status of all layers and reuse it

A forum dedicated to George scripting questions
Post Reply
Zetariver
Posts: 77
Joined: 23 Dec 2013, 07:58

Store visibility status of all layers and reuse it

Post by Zetariver »

Hello. I want to record visibility status of all layers and reuse it.
I want to do something like those scripts.Those scripts wont't work, but at least it will explain what I want to do.

Script A

Code: Select all

loop= 1
i= 0
WHILE loop
	tv_LayerGetID i
	curLID= result   
	IF CMP(curLID,"NONE")==0    
		tv_layerSet curLID   
		tv_LayerDisplay
		LayerState = result
		LAYER_V_STATE[i] = LayerState
		i= i+1   
	ELSE      
		loop=0
	END
END
Script B

Code: Select all

loop= 1
i= 0
WHILE loop
	tv_LayerGetID i
	curLID= result   
	IF CMP(curLID,"NONE")==0    
		tv_layerSet curLID  
		LAYER_V_STATE[i] 
		VS = result
		if  (VS== "ON")
			tv_LayerDisplay State "On"
		else
			tv_LayerDisplay State "Off"
		END	
		i= i+1   
	ELSE      
		loop=0
	END
END
I want to get visibility status of all layers and save them in array "V_STATE". Script A does it.
And I want all layers to revert back to previous visibility status, Script B does it.
Is it possible in TVpaint? I need to isolate some layers often, so I need a script that can do that.
Please tell me what should I do to do that. Thank you.
User avatar
Paul Fierlinger
Posts: 8100
Joined: 03 May 2008, 12:05
Location: Pennsylvania USA
Contact:

Re: Store visibility status of all layers and reuse it

Post by Paul Fierlinger »

If I understand you properly this can already be done in TVP. It sounds like you want to hide some layers while others are kept visible. With something called, Layer Attenuation you can keep one layer 100% visible while all the others can be dimmed down to any percentage point you desire, for instance just 20% so that you still see them but very slightly. This feature can be found in the Display Settings Panel, depending on which version of TVP you have. Which version do you have?
Paul
http://www.slocumfilm.com
Desktop PC Win10-Pro -64 bit OS; 32.0 GB RAM
Processor: i7-2600 CPU@3.40GHz
AMD FirePro V7900; Intuos4 Wacom tablet
Svengali
Posts: 1553
Joined: 28 Dec 2006, 10:08

Re: Store visibility status of all layers and reuse it

Post by Svengali »

Where / how to reliably store the Display States for all the layers so they can then be retrieved and restored is what I think you are trying to do?

Here are two functions: one that saves all of the layers' Display States in a simple string which is then stored in the CONFIG.INI file using the tv_WriteUserString command, then retrieved with the second function using the tv_ReadUserString command.

The generated string contains a list of numbers, for example 5 1 0 0 1 1. This means there are a total of five layers, with layers 2 and 3 NOT displayed.

Using the string to store all of the layer Display States bypasses the need to create an array and a file to store that data in. I suppose the string-packing technique could be adapted in a script to let the user store a whole series of strings for different layer Display State combinations for a scene... maybe using layer names to group layers (instead of layer colors) to make different layer groups visible or hidden?

Sven
Attachments
LayerDisplayStates.tvpx
(87 KiB) Downloaded 165 times
TVP Pro 11.0.10-64bit Win10 - 64GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.41-1
Android Tablet: rel. 11, Samsung Galaxy Note10.1 - 32GB with microSD 32GB
Android Tablet: rel. 11.5, Samsung Galaxy Tab S7plus - 128GB with microSD 64GB
Zetariver
Posts: 77
Joined: 23 Dec 2013, 07:58

Re: Store visibility status of all layers and reuse it

Post by Zetariver »

To Paul
Thank you for your comment, but Layer Attenuation is not what I need. I need to isolate more than 2 layers and add some quick fixes all the time, so I need to store layer visibility status.

To Svengali
Yes! It's what I wanted. And thank you for your info. I read a topic where you talked about
tv_WriteUserString and tv_ReadUserString, but I couldn't understand how to use it and I wrote this and of course it didn't work because of double quotation marks.

Code: Select all

loop= 1
i= 0
WHILE loop
	tv_LayerGetID i
	curLID= result   
	IF CMP(curLID,"NONE")==0    
		tv_layerSet curLID   
		tv_LayerDisplay
		LayerState = result
		tv_WriteUserString "LAYER_V_STATE[i]" "Layer_Visibility" LayerState
		i= i+1 
	ELSE      
		loop=0
	END
END
I use layer groups, but sometimes I need to isolate a part of layer groups or layers from more than 2 layer groups, so I need a script.
Anyway thank you for your script. I will check your script and of course I will use it forever.
Post Reply