|
Toshihiro Shimizu |
890ddd |
export = {}; -- create a new export object
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- return label
|
|
Toshihiro Shimizu |
890ddd |
function export:label()
|
|
Toshihiro Shimizu |
890ddd |
return "Toonz";
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- return category
|
|
Toshihiro Shimizu |
890ddd |
function export:category()
|
|
Toshihiro Shimizu |
890ddd |
return "2D";
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- return argument list
|
|
Toshihiro Shimizu |
890ddd |
function export:options()
|
|
Toshihiro Shimizu |
890ddd |
groups = {};
|
|
Toshihiro Shimizu |
890ddd |
for a,actor in magpie.getactors() do
|
|
Toshihiro Shimizu |
890ddd |
for g,group in magpie.getgroups(actor) do
|
|
Toshihiro Shimizu |
890ddd |
table.insert(groups, group);
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
return {
|
|
Toshihiro Shimizu |
890ddd |
{"group", "Group", "choice", table.concat(groups, "|")},
|
|
Toshihiro Shimizu |
890ddd |
{"toonz_output_file", "Output File", "output_file", "Text files (*.tls)\tAll files (*.*)"}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- perform the export
|
|
Toshihiro Shimizu |
890ddd |
function export:run(from, to, options)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- open output file
|
|
Toshihiro Shimizu |
890ddd |
fd = io.open(options.toonz_output_file, "wt");
|
|
Toshihiro Shimizu |
890ddd |
if (fd == nil) then
|
|
Toshihiro Shimizu |
890ddd |
return string.format("could not open '%s'", options.toonz_output_file);
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- write header line to file
|
|
Toshihiro Shimizu |
890ddd |
fd:write("Toonz\n");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- create an array of all the poses that are being exported
|
|
Toshihiro Shimizu |
890ddd |
line = "";
|
|
Toshihiro Shimizu |
890ddd |
poses = magpie.getposes(options.group);
|
|
Toshihiro Shimizu |
890ddd |
for p,pose in poses do
|
|
Toshihiro Shimizu |
890ddd |
line = string.gsub(pose, "[^%.]+%.", "");
|
|
Toshihiro Shimizu |
890ddd |
fd:write(line, "\n");
|
|
Toshihiro Shimizu |
890ddd |
line = "";
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- write data to file
|
|
Toshihiro Shimizu |
890ddd |
for frame = from, to do
|
|
Toshihiro Shimizu |
890ddd |
line = "";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
line = frame + magpie.getframeoffset();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
k = nil;
|
|
Toshihiro Shimizu |
890ddd |
k = magpie.getgroupvalue(frame, options.group);
|
|
Toshihiro Shimizu |
890ddd |
if (k ~= nil) then
|
|
Toshihiro Shimizu |
890ddd |
k = string.gsub(k, "[^%.]+%.", ""); -- remove actor and group name from string
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
if (k == nil) then
|
|
Toshihiro Shimizu |
890ddd |
k = "<none>";</none>
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (line ~= "") then
|
|
Toshihiro Shimizu |
890ddd |
line = line .. "|";
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
line = line .. k;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (line ~= "") then
|
|
Toshihiro Shimizu |
890ddd |
line = line .. "|";
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
comment = magpie.getframecomment(frame);
|
|
Toshihiro Shimizu |
890ddd |
if (comment ~= "") then
|
|
Toshihiro Shimizu |
890ddd |
is_empty = false;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
comment = "<none>";</none>
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
line = line .. comment;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
fd:write(line, "\n");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
-- update progress bar in main window
|
|
Toshihiro Shimizu |
890ddd |
magpie.progress("Exporting...", (frame - from) / (to - from));
|
|
Toshihiro Shimizu |
890ddd |
end
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
magpie.progress("", 0); -- close progress bar
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
fd:close(); -- close output file
|
|
Toshihiro Shimizu |
890ddd |
end
|