Lukas wrote:
I've put it in an embedded george script in a button, but so far all I'm getting is "TVP PROJECT IS NOT SAVED".
The script should work the way that it creates a folder in the same fplder as the tvpp file is saved, and the folder have the same name as the tvpp file. So if the tvpp file is not saved somewhere the script will not work.
But here it is probably the filepath with whitespace issue. see below
Lukas wrote:
I don't understand what this part does:
Code: Select all
tv_WriteTextFile "Exists" projectpath
testPath = result
We can check if a folder/ files exists with the command tv_WriteTextFile "Exists" filePath
I check if the project path to the tvpp file exists to see if the tvpp project is saved and there by there is a folder I can save the TIFF.
If the filePath exists the goerge command will return the filepath if not it will return nothing.(I think)
http://wiki.tvpaint.fr/index.php?title=Tv_WriteTextFile
I can see i forgot to enclose the filePath with '"' to make it work with filepath that have white spaces inside
Here is a new version.
Code: Select all
PARAM none
tv_saveMode "TIFF"
ext = ".tif"
tv_AlphaSaveMode "None"
tv_Background "COLOR"
tv_GetProjectName
projectpath = result
tv_WriteTextFile "Exists" '"'projectpath'"'
testPath = result
IF CMP(testPath,projectpath)==0
tv_warn "TVP PROJECT IS NOT SAVED"
ELSE
tv_layerGetImage
startImage = result
projectpath = Replace(projectpath,'\','/')
strlen = LEN(projectpath)
last = LastPos(projectpath,"/")
projectdir = LeftString(projectpath,last-1)
projectname = RightString(projectpath,strlen-last)
strlen = LEN(projectname)
last = LastPos(projectname,".")
IF CMP(last,"0")==1
projectbase = projectname
ELSE
projectbase = LeftString(projectname,last-1)
END
saveDir = projectdir"/"projectbase
tv_WriteTextFile "Remove" '"'saveDir'"'
tv_WriteTextFile "MkDir" '"'saveDir'"'
//get clip in
tv_markIn clip
PARSE result frame state
IF CMP(state,"set ")==1
inpoint = frame
ELSE
tv_firstImage
inpoint = result
END
//Get Clip Out
tv_markOut clip
PARSE result frame state
IF CMP(state,"set ")==1
outpoint = frame
ELSE
tv_LastImage
outpoint = result
END
//findProjectinout
tv_layerImage inpoint
tv_projectcurrentframe
projIN = result
tv_projectcurrentframe projIN
tv_layerImage outpoint
tv_projectcurrentframe
projOUT = result
tv_projectcurrentframe projOUT
tv_clipname
clipName = result
tv_startFrame
startFrame = inpoint+result
renderFile = saveDir"/"clipName"_000"startFrame""ext
tv_projectsavesequence '"'renderFile'"' projIN projOUT "camera"
tv_layerImage startImage
END
//{{{ Find
//------------------------------------------
//
// Find
//
// Function: find a character into a string
// from a specified start position
//
// Call: Find(string,car,start)
//
// Arguments:
// string = characters string
// car = character to look for
// start = start position in string
//
// Return: position of character
// 0 if character does not exist
// into string
// -1 if invalid position
// (negative, null or higher
// than string length)
//
//------------------------------------------
FUNCTION Find(string,car,start)
LOCAL i size
i = start
size = LEN(string)
IF ((start <= 0) || (start > size) || (CMP(car,"") == 1))
RETURN -1
END
DO
IF (CMP(CHAR(string,i),car) == 1)
RETURN i
END
UNTIL ((i=i+1) > size)
RETURN 0
END
//}}}
//{{{ FirstPos(string,car)
//------------------------------------------
//
// FirstPos
//
// Function: find first occurence of a
// character into a string
//
// Call: FirstPos(string,car)
//
// Arguments:
// string = characters string
// car = character to look for
//
// Return: position of character
// or 0 id character does not
// exist into string.
//
//------------------------------------------
FUNCTION FirstPos(string,car)
RETURN Find(string,car,1)
END
//}}}
//{{{ LastPos(string,car)
//------------------------------------------
//
// LastPos
//
// Function: find last occurence of a
// character into a string
//
// Call: LastPos(string,car)
//
// Arguments:
// string = characters string
// car = character to look for
//
// Return: position of character
// or 0 if character does not
// exist into string.
//
//------------------------------------------
FUNCTION LastPos(string,car)
LOCAL loop myChar
pos = LEN(string)
loop = 1
WHILE loop
myChar = CHAR(string,pos)
IF CMP(myChar,car) == 1
loop =0
ELSE
pos = pos-1
END
IF pos<1
loop=0
END
END
RETURN pos
END
//}}}
//{{{ FindString(string,search,start)
//------------------------------------------
//
// FindString
//
// Function: find a substring into a string
// from a specified start position
//
// Call: FindString(string,search,start)
//
// Arguments:
// string = characters string
// search = substring to look for
// start = start position in string
//
// Return: start position of substring
// 0 if substring does not exist
// into string
// -1 if invalid start position
// (negative, null or higher
// than string length) or if
// substring is empty
//
//------------------------------------------
FUNCTION FindString(string,search,start)
LOCAL found j pos lastpos lstr lsrch
found = 0
lastpos = start
lstr = LEN(string)
lsrch = LEN(search)
IF (CMP(search,"") == 1)
RETURN -1
END
WHILE ((pos = Find(string,CHAR(search,1),lastpos)) > 0)
j = 1
found = 1
IF (j == lsrch)
RETURN pos
END
WHILE ((j < lsrch) && (found == 1))
IF ((pos+j) > lstr)
RETURN 0
ELSE
IF (CMP(CHAR(search,j+1),CHAR(string,pos+j)) == 0)
lastpos = pos+j
found = 0
END
END
j = j+1
END
IF (found == 1)
RETURN pos
END
END
RETURN pos
END
//}}}
//{{{ LeftString(string,number)
//------------------------------------------
//
// LeftString
//
// Function: extract a substring beginning
// at the start of a string
//
// Call: LeftString(string,number)
//
// Arguments:
// string = characters string
// number = number of character to
// extract from string
//
// Return: result substring
// or 0 if number is negative
// or null.
//
//------------------------------------------
FUNCTION LeftString(string,number)
LOCAL size
size = LEN(string)
IF (number > 0)
IF (number > size)
number = size
END
RETURN CUT(string,1,number)
END
RETURN 0
END
//}}}
//{{{ RightString(string,number)
//------------------------------------------
//
// RightString
//
// Function: extract a substring ending
// at the end of a string
//
// Call: RightString(string,number)
//
// Arguments:
// string = characters string
// number = number of character to
// extract from string
//
// Return: result substring
// or 0 if number is negative
// or null.
//
//------------------------------------------
FUNCTION RightString(string,number)
LOCAL size
size = LEN(string)
IF (number > 0)
IF (number > size)
number = size
END
RETURN CUT(string,size-number+1,size)
END
RETURN 0
END
//}}}
//{{{ MidString(string,first,size)
//------------------------------------------
//
// MidString
//
// Function: extract a substring from a
// string
//
// Call: MidString(string,first,size)
//
// Arguments:
// string = characters string
// first = start position in string
// cha�ne
// size = number of characters
//
// Return: result substring
// or 0 if number or first are
// negatives or null.
//
//------------------------------------------
FUNCTION MidString(string,first,size)
LOCAL ln
ln = LEN(string)
IF ((first > 0) && (size > 0))
IF ((first+size-1) > ln)
size = ln-first+1
END
RETURN CUT(string,first,first+size-1)
END
RETURN 0
END
//}}}
//{{{ Replace
//------------------------------------------
//
// Replace
//
// Function: replace each occurence of a
// substring into a string with
// another string
//
// Call: Replace(string,search,repl)
//
// Arguments:
// string = characters string
// search = substring to look for
// repl = replacement substring
//
// Return: result string after replacement
//
//------------------------------------------
FUNCTION Replace(string,search,repl)
LOCAL pos workstr str1 str2 size
pos = 1
workstr = string
size = LEN(search)
WHILE ((pos = FindString(workstr,search,pos)) > 0)
IF (pos == 1)
str1 = CUT(workstr,size+1,LEN(workstr))
workstr = repl""str1
pos = 0
ELSE
str1 = CUT(workstr,1,pos-1)
IF ((pos+size) < LEN(workstr))
str2 = CUT(workstr,pos+size,LEN(workstr))
workstr = str1""repl""str2
ELSE
workstr = str1""repl
END
END
pos = pos+LEN(repl)
END
RETURN workstr
END
//}}}