| export = {}; |
| |
| |
| function export:label() |
| return "Toonz"; |
| end |
| |
| |
| function export:category() |
| return "2D"; |
| end |
| |
| |
| function export:options() |
| groups = {}; |
| for a,actor in magpie.getactors() do |
| for g,group in magpie.getgroups(actor) do |
| table.insert(groups, group); |
| end |
| end |
| return { |
| {"group", "Group", "choice", table.concat(groups, "|")}, |
| {"toonz_output_file", "Output File", "output_file", "Text files (*.tls)\tAll files (*.*)"} |
| }; |
| end |
| |
| |
| function export:run(from, to, options) |
| |
| |
| fd = io.open(options.toonz_output_file, "wt"); |
| if (fd == nil) then |
| return string.format("could not open '%s'", options.toonz_output_file); |
| end |
| |
| |
| fd:write("Toonz\n"); |
| |
| |
| line = ""; |
| poses = magpie.getposes(options.group); |
| for p,pose in poses do |
| line = string.gsub(pose, "[^%.]+%.", ""); |
| fd:write(line, "\n"); |
| line = ""; |
| end |
| |
| |
| for frame = from, to do |
| line = ""; |
| |
| line = frame + magpie.getframeoffset(); |
| |
| k = nil; |
| k = magpie.getgroupvalue(frame, options.group); |
| if (k ~= nil) then |
| k = string.gsub(k, "[^%.]+%.", ""); |
| end |
| if (k == nil) then |
| k = "<none>"; |
| end |
| |
| if (line ~= "") then |
| line = line .. "|"; |
| end |
| line = line .. k; |
| |
| if (line ~= "") then |
| line = line .. "|"; |
| end |
| |
| comment = magpie.getframecomment(frame); |
| if (comment ~= "") then |
| is_empty = false; |
| else |
| comment = "<none>"; |
| end |
| line = line .. comment; |
| |
| fd:write(line, "\n"); |
| |
| |
| magpie.progress("Exporting...", (frame - from) / (to - from)); |
| end |
| |
| magpie.progress("", 0); |
| |
| fd:close(); |
| end |