Hi Grant!
I’ll explain some of the stuff I figured out. George is a bit of a funny language, and since you didn’t work with the more complicated stuff I’ll explain it. Sorry if I’m retreading known ground for you. Also, as far as I could find there was no way to pass parameters into a script called from the commandline. That was one of the reasons that I found using the individual argument syntax helpful, since I could pass parameters to those.
Sorry this is such a long post, but feel free to take your time reading through and following. Also ask for more detail if I’ve made parts too confusing.
Some notes about these solutions. George has a funny way of returning values from functions. When you call a function, it will then return a value to the keyword ‘result’ on the next line after the function call. You don’t seem to be able to set the value on the same line as the return statement.
Also the way to check equivalence is to wrap two parameters in a CMP() function (which I assume is short for Compare) and seeing if it returns as True or False.
String concatenation is tricky to follow too, because George will attach variables and quoted literals together. And to attach two variables together, you need to put an empty string between them. It’s probably easiest to show by examples:
[code]name = “George”
num = “001”
filetype = “.grg”
//With these you can make
name’.png’ >> “George.png”
name’‘num >> “George_001”
name’‘num’'filetype >> “George_001.png”[/code]
Lastly, when you want to get a set of different values from a result, you use the keyword PARSE and then a set of variable names to save the different values into.
Hopefully those explanations make sense, I’m not very clear on how these work myself but I can try explain more if you need me to.
The first thing I was looking into was being able to export layers as separate images. The main problem I found with doing this was how to tell what layers existed in the document. I never found out a way to read that effectively for the script, however I did discover that their unique IDs are pretty simple (starting at 1 and incrementing) and that TVPaint doesn’t throw an error for trying to select an invalid ID. So I actually set up a script that would loop through every possible ID number from 1 to 10000, checking if they corresponding to an actual layer. It works quite well, and there’s no lag at all, it passes by the invalid IDs incredibly quickly.
Anyway, here’s the script:
[code]//All the preparation code for setting background mode and filetype goes above here
//This changes a setting so that only the currently selected layer will display/render
tv_Display “current”
//It returns the previous display mode as a result, which can be saved and restored after the script is done.
display = result
FOR id = 1 to 10000
//Using the id, attempt to select a layer.
tv_LayerSet id
//Check if we successfully selected a layer
IF (CMP(result,'') == 1)
//Now get the information for the currently selected layer, just so we have the layerName
tv_LayerInfo
PARSE result layerDisplay layerPosition layerOpacity layerName layerType layerStart layerEnd layerPrelighttable layerPostlighttable
//Render frames now, since this is a real layer
tv_savesequence filename'_'layerName''filetype frameIn frameOut "Camera"
END
END
tv_Display result
[/code]
So this loops over all possible layers (up to 10000, but that number could be increased if it ever seemed to be necessary) and then just exports the frame range of it. The filename is generated from the layer’s name. You could also separate them into different folders just by adding a slash and folder name, as long as you run the folder creation before the George script.
I also found some ways to test frames and layers. TVPaint frames have an attribute called ‘exposureinfo’ that tells you if there’s actually a new drawing on that layer. Often there are holds on individual layers, where the same image is sustained over a period of time. Using this, I was able to prevent every single frame from every single layer exporting, I was able to only export the necessary frames.
This is how it works: (this goes in the if block that tests if a layer ID is real)
NOTE: This solution makes use of a function that someone on the TVPaint forums wrote. It’s helpful for padding a frame number out to have the right number of digits. To include a function, just add it at the end of the script, after all the main code.
[code]FOR i = frameIn TO frameOut
//Use i to check exposure info on the current frame
tv_exposureinfo i
IF (CMP(result,“Head”) == 1)
//Head means that there’s a new key, so this frame should be exported
// Make a filename for this frame
name = string_addZeros(’_’,i,5)
filename = ‘"‘projname’‘layerName’‘name’.png"’
tv_savesequence filename i i “Camera”
END
END
//Here’s the addZeros function.
FUNCTION string_addZeros(prefix,digit,length)
LOCAL cur i
length=length1
digit=digit1
cur = LEN(digit)
length=length-1
FOR i=cur TO length
prefix=prefix"0"
END
prefix =prefix""digit
result = prefix
RETURN result
END[/code]
I think I’ll stop there for now, I have a bit more. Like how to test if a layer or frame are marked with a certain colour and render on that basis. But this is lots to read already, so I’ll post about that another time.
Hope this helps and is clear!
Gary