Page 1 of 1
Rename layer automatically
Posted: 24 Apr 2013, 10:41
by Lukas
I'm looking for a command to automatically change layer names from "Man" to "Man Color" and "Woman" to "Woman Color"
Is there a way to do it with an embedded George script?
Also, what's the best resource to learn some George scripting?
Re: Rename layer automatically
Posted: 24 Apr 2013, 12:06
by Mads Juul
A quick introduction to George
this code will rename layer.
Code: Select all
tv_LayerCurrentID
curID = result
tv_LayerInfo curID
PARSE result layerDisplay layerPosition layerOpacity layerName layerType layerStart layerEnd layerPrelighttable layerPostlighttable layerSelection
newName = layerName"_COLOR"
tv_LayerRename curID newName
When using George, using whitespaces is a little cumbersome among other things Because of the PARAM function which splits string into variable at each whitespace, for this reason this script calls the new layer
"man_COLOR" instead of "man COLOR"
here with explaination and link yo the George WIKI
Code: Select all
tv_LayerCurrentID
// the function 'tv_LayerCurrentID' gets the layer id of the current layer and stores it automatically in a variable called 'result' I need the layer id for the functions 'tv_LayerInfo' and 'tv_LayerRename'
http://wiki.tvpaint.fr/index.php?title= ... rCurrentID
Code: Select all
curID = result
//create a new vareiabel and store the value of 'result' in it bacause 'result' is used to store the return valueof the different functions in GEORGE
Code: Select all
tv_LayerInfo curID
// tv_LayerInfo is a function that returns info about the layer and stores it in the varable called "result"
http://wiki.tvpaint.fr/index.php?title=Tv_LayerInfo
Code: Select all
PARSE result layerDisplay layerPosition layerOpacity layerName layerType layerStart layerEnd layerPrelighttable layerPostlighttable layerSelection
// Wath PARSE , I split the input variable (here result) every time there is a whitespace and stores them in the new vaiable
http://wiki.tvpaint.fr/index.php?title=PARSE
Code: Select all
newName = layerName" COLOR"
// I create a new variable from the current name
http://wiki.tvpaint.fr/index.php?title=Tv_LayerRename
Code: Select all
tv_LayerRename curID newName
// I rename layer with the function 'tv_layerRename'
http://wiki.tvpaint.fr/index.php?title=Tv_LayerRename
Here is a introdiction to George
http://wiki.tvpaint.fr/index.php?title=George
here is a list of Commands
http://wiki.tvpaint.fr/index.php?title= ... _Reference
List of George instructions
http://wiki.tvpaint.fr/index.php?title= ... _Reference
and is any question please ask at the forum for George
http://forum.tvpaint.com/viewforum.php?f=34
-Mads
P.S A nice function to use to see whats going on in your script is 'tv_warn'
http://wiki.tvpaint.fr/index.php?title=Tv_Warn
Re: Rename layer automatically
Posted: 24 Apr 2013, 12:49
by Lukas
Wow, thanks for your time Mads!
My brain is consuming as much as possible
Re: Rename layer automatically
Posted: 08 May 2013, 09:30
by Lukas
I thought it was fine, but I'm having some trouble with using _ instead of a space
I'm trying to somehow seperate colored layers (so I can toggle all colored layers' visibility with 1 button)
I'm trying to learn by just doing it, so bear with me...
I thought if I named all my layers
- guy line
- guy color
- girl line
- girl color
etc
I could somehow use something like this
Code: Select all
tv_LayerInfo
PARSE result layerDisplay layerPosition layerOpacity layerName layerType layerStart layerEnd layerPrelighttable layerPostlighttable layerSelection
PARSE layerName word1 word2 word3 word4
IF CMP(word2, color)
tv_LayerDisplay LayerID Off
ELSE
tv_LayerDisplay LayerID On
END
(allthough I have no idea yet how to run and use this for all layers in a project...but i'll get there :p)
Is there a way to get around using "_" and use a space anyway, or is this just not gonna work this way?