Store persistent reference to a layer

A forum dedicated to George scripting questions
Post Reply
User avatar
Bram Vermaas
Posts: 3
Joined: 08 Feb 2022, 13:46
Contact:

Store persistent reference to a layer

Post by Bram Vermaas »

Hello TVPaint gurus!

I'm looking for some advice on how best to get a persistent reference to a layer.

In the pipeline of Submarine we would like to mark certain layers of a TVPaint file for export.
The 2 types of export we currently support are renderLayers and renderPasses.
RenderPasses are a subset of renderLayers. For example the renderLayer "Henry" can have the renderPasses "Lines" and "Color".

We mark renderLayers using the layer color index (as returned by tv_layercolor "get" ).
This works as expected, no problem there.

For renderPasses we tried storing the layerIds (as returned by tv_layergetid).
But after testing, we found that the layerIds are not persistent.
For example, opening only file "A" leads to different layerIds than when opening file "B" first and then file "A".
Also deleting a layer and later re-opening the file leads to changed layerIds of all layers under the deleted layer.

A second option we considered was using the layerName (as returned by tv_layerinfo)
But as names are so easily changed by the artist, it's a route we would like to avoid.

Personally I'm quite new to TVPaint, and so probably overlooked some advanced methods.
If anyone knows a good way of getting a persistent reference to a layer, you can make one dutch pipeline TD very happy.
User avatar
NathanOtano
Posts: 1187
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: Store persistent reference to a layer

Post by NathanOtano »

I agree that persistent layer ids, clip ids and instance ids wouls immensely help for import/export and updating

What I try to do is t make my export scripts rename and unconventional name to a specific ID, I store in a userstring variable that I increment over time so it is never the same in time. Then if the name is conventional, I never rename it afterward. If anybody renames it non-conventional, I add an ID at the beginning of the name everytime. Only problem is if an ID is present two times
I feel the names are the only way to do what you want
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
Bram Vermaas
Posts: 3
Joined: 08 Feb 2022, 13:46
Contact:

Re: Store persistent reference to a layer

Post by Bram Vermaas »

Hi Nathan,

Thanks for your response. Indeed it looks like the layer names are the only way to persistently reference layers.
What we do for now is add a "<tag>" at the end of a layer name, coupled with some validation before export.

For example:

Code: Select all

my_layername_<RenderPassHenryColor>
User avatar
NathanOtano
Posts: 1187
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: Store persistent reference to a layer

Post by NathanOtano »

Nice solution! Thanks :)
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
Post Reply