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: 267
Joined: 26 Sep 2013, 12:01

Need help in making script to hop between two layers

Post by TheQuestionMark »

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.5.3 (64-Bit)
User avatar
slowtiger
Posts: 2889
Joined: 08 May 2008, 21:10
Location: berlin, germany
Contact:

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

Post by slowtiger »

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 and 11.0 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
TVP 11.0 and 11.7 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
TVP 11.7 Mac Mini M2pro 32GB OS 13.5
Svengali
Posts: 1552
Joined: 28 Dec 2006, 10:08

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

Post by Svengali »

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.
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
TheQuestionMark
Posts: 267
Joined: 26 Sep 2013, 12:01

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

Post by TheQuestionMark »

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.5.3 (64-Bit)
TheQuestionMark
Posts: 267
Joined: 26 Sep 2013, 12:01

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

Post by TheQuestionMark »

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.5.3 (64-Bit)
Svengali
Posts: 1552
Joined: 28 Dec 2006, 10:08

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

Post by Svengali »

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
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
Post Reply