Need help in making script to hop between two layers Topic is solved

Please use this part to report bugs & errors, ask questions & "How to..."
Post Reply
TheQuestionMark
Posts: 193
Joined: 26 Sep 2013, 12:01

Need help in making script to hop between two layers

Post by TheQuestionMark » 18 Apr 2020, 12:07

I was wonder can anyone make a command or script where you can hop between two layers? I would like hop between the current layer and line layer. I was wondering if it can hop to any selection of within 3 of color layers if I select it but it always land back to "Line" Layer, and it goes back and forth. I have alot between layers that's in the middle of the color and line layer, it's a real hassle to tap keyboard several times. Is there such thing as script for it?
Windows 10 64-Bit TvPaint Professional 11.0.9 (64-Bit)

User avatar
slowtiger
Posts: 2480
Joined: 08 May 2008, 21:10
Location: berlin, germany
Contact:

Re: Need help in making script to hop between two layers

Post by slowtiger » 18 Apr 2020, 15:28

I'm just guessing: if you put all these layers in the same group, maybe the script can jump easily between these?
TVP 10.0.18, Mac Pro Quadcore 3 GHz, 16 GB RAM, OS 10.11, QT 7.7.3

Svengali
Posts: 1309
Joined: 28 Dec 2006, 10:08
Contact:

Re: Need help in making script to hop between two layers

Post by Svengali » 19 Apr 2020, 00:24

This script "ToggleLineLayer.grg" can be embedded and should do what you want.

Follow these steps and pay attention to step 5. where you must SUBSTITUTE the line name you want to toggle to...
1. create a new Action button
2. in the code box below click on SELECTALL
3. Edit the Action button to create an Ebedded George Script
4. In the "Type Script's Command" box, paste the script

5. IMPORTANT: locate and Edit the following line in the SCRIPT:
LineLayer = "name of line layer you want to toggle to"

6. Select OK to close the "Type Script's Command" box
7. Select OK to save the Action button
8. Test the button: it should toggle between your line layer and whatever other, current layer you are working on

Code: Select all

// ToggleLineLayer.grg
// Svengali © 2020
// ( april ) 2020 - ver .0
//     toggles between any current layer and linelayer

Param none
ScriptName = "ToggleLineLayer"

LineLayer = "name of line layer you want to toggle to"			// put the name of the line layer here INSIDE QUOTATION MARKS

tv_LayerCurrentID
OrigLayerID = result
tv_LayerInfo OrigLayerID
parse result d d d LayerName d
IF CMP(LayerName,LineLayer) == 0
	tv_WriteUserString "ToggleLineLayer" "OrigLayerID" OrigLayerID
	FindLineLayer()
ELSE
	tv_ReadUserString "ToggleLineLayer" "OrigLayerID" 
	OrigLayerID = result
	tv_LayerSet OrigLayerID
END


FUNCTION FindLineLayer()
	
	Counter = 0
	LineLayerID = 0
	LayerFlag = 1
	While LayerFlag == 1
		tv_LayerGetID Counter
		LineLayerID = result
		tv_LayerInfo LineLayerID
		parse result d d d LayerName d
		IF CMP(LayerName,LineLayer)
			tv_LayerSet LineLayerID
			LayerFlag = 0
		END
		IF CMP(LineLayerID,"none")
			tv_warn LineLayer "not found... aborting"
			LayerFlag = 0
		END
		Counter = Counter + 1
	END
END
Sven
Last edited by Svengali on 27 Apr 2020, 13:52, edited 1 time in total.
Desktop: tvp Pro 11.0.10-64bit, Win8.1 - 24GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.36-1
Android Tablet: release 11, Samsung Galaxy Note10.1 - 32GB internal - microSD 32GB

TheQuestionMark
Posts: 193
Joined: 26 Sep 2013, 12:01

Re: Need help in making script to hop between two layers

Post by TheQuestionMark » 20 Apr 2020, 03:09

slowtiger wrote:
18 Apr 2020, 15:28
I'm just guessing: if you put all these layers in the same group, maybe the script can jump easily between these?
I'm not sure I really need a group? I just need to hop to line layer and with the current layer, the color layer. I have 3 color layers, but I just want the color layer I'm on and want to hop back to line layer, back and forward.
Windows 10 64-Bit TvPaint Professional 11.0.9 (64-Bit)

TheQuestionMark
Posts: 193
Joined: 26 Sep 2013, 12:01

Re: Need help in making script to hop between two layers

Post by TheQuestionMark » 20 Apr 2020, 03:18

Svengali wrote:
19 Apr 2020, 00:24
This script "ToggleLineLayer.grg" can be embedded and should do what you want.

Follow these steps and pay attention to step 5. where you must SUBSTITUTE the line name you want to toggle to...
1. create a new Action button
2. in the code box below click on SELECTALL
3. Edit the Action button to create an Ebedded George Script
4. In the "Type Script's Command" box, paste the script

5. IMPORTANT: locate and Edit the following line in the SCRIPT:
LineLayer = "name of line layer you want to toggle to"

6. Select OK to close the "Type Script's Command" box
7. Select OK to save the Action button
8. Test the button: it should toggle between your line layer and whatever other, current layer you are working on

Code: Select all

// ToggleLineLayer.grg
// Svengali © 2020
// ( april ) 2020 - ver .0
//     toggles between any current layer and linelayer

Param none
ScriptName = "ToggleLineLayer"

LineLayer = "name of line layer you want to toggle to"			// put the name of the line layer here INSIDE QUOTATION MARKS

tv_LayerCurrentID
OrigLayerID = result
tv_LayerInfo OrigLayerID
parse result d d d LayerName d
IF CMP(LayerName,LineLayer) == 0
	tv_WriteUserString "ToggleLineLayer" "OrigLayerID" OrigLayerID
	FindLineLayer()
ELSE
	tv_ReadUserString "ToggleLineLayer" "OrigLayerID" 
	OrigLayerID = result
	tv_LayerSet OrigLayerID
END


FUNCTION FindLineLayer()
	
	Counter = 0
	LineLayerID = 0
	LayerFlag = 1
	While LayerFlag == 1
		tv_LayerGetID Counter
		LineLayerID = result
		tv_LayerInfo LineLayerID
		parse result d d d LayerName d
		IF CMP(LayerName,LineLayer)
			tv_LayerSet LineLayerID
			LayerFlag = 0
		END
		IF CMP(LineLayerID,"none")
			tv_warn LineLayer "not found... aborting"
			LayerFlag = 0
		END
		Counter = Counter + 1
	END
END
]
Sven
Thank you this is exactly what I wanted! I guess writing the code is complicated then what I imagine in my mind. Thanks!
Windows 10 64-Bit TvPaint Professional 11.0.9 (64-Bit)

Svengali
Posts: 1309
Joined: 28 Dec 2006, 10:08
Contact:

Re: Need help in making script to hop between two layers

Post by Svengali » 20 Apr 2020, 13:14

Happy to help.
Actually, the script is pretty simple and uses a standard method to loop through all layers to find one (or more) specific layer(s) with some characteristic like name, or status.

It also uses the config.ini file to store and retrieve data so dynamic information that changes can be passed between scripts.

Sven
Desktop: tvp Pro 11.0.10-64bit, Win8.1 - 24GB ram -2TB HHD - 256GB SSD - Wacom Cintiq 16, driver 6.3.36-1
Android Tablet: release 11, Samsung Galaxy Note10.1 - 32GB internal - microSD 32GB

Post Reply