Created
December 12, 2017 16:43
-
-
Save melMass/d3bae3a2d58b92af0ef0f16a3052c2ee to your computer and use it in GitHub Desktop.
# Simple script to extract read nodes from the comp and sequence them to a one track EDL for DI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################### | |
# File name: edl_write # | |
# Author: Mel Massadian # | |
# Submission: 12/12/17 # | |
#################################### | |
import os | |
import sys | |
from timecode import Timecode | |
NAME = nuke.root().name().split(os.path.sep)[-1].replace(".nk","") | |
FPS = nuke.root()["fps"].value() | |
SHOTS = list() | |
EDL_TC = Timecode(fps, '00:00:00:00') | |
OUT = "TITLE: {}\n\n".format(name) | |
SHOT_ID = 1 | |
for x in nuke.allNodes(): | |
if x.Class() == "Read": | |
SHOT_NAME = x.knob('file').value().split(os.path.sep)[-1] | |
# read Read nodes | |
FIRST_FRAME = x.knob("first").value() | |
LAST_FRAME = x.knob("last").value() | |
# add duration to the EDL's TC | |
SHOT_DURATION = LAST_FRAME - FIRST_FRAME | |
EDL_TC_FIRST = str(EDL_TC) | |
EDL_TC += SHOT_DURATION | |
EDL_TC_LAST = str(EDL_TC) | |
FIRST_TC = EDL_TC.frames_to_tc(FIRST_FRAME) | |
FIRST_TC = EDL_TC.tc_to_string(*FIRST_TC) | |
LAST_TC = EDL_TC.frames_to_tc(LAST_FRAME) | |
LAST_TC = EDL_TC.tc_to_string(*LAST_TC) | |
OUT += "{:03d} AX V C {} {} {} {}\n* FROM CLIP NAME: {}\n\n".format(SHOT_ID, FIRST_TC, LAST_TC, EDL_TC_FIRST, EDL_TC_LAST, SHOT_NAME) | |
SHOT_ID += 1 | |
def writeEDL(path,content): | |
if os.path.isfile(path): | |
if not nuke.ask('A file exist\nAre you sure you want to overwrite the EDL ?'): | |
return | |
try: | |
with open(path,'w') as f: | |
f.write(content) | |
except: | |
print(sys.exc_info()[0]) | |
finally: | |
if os.path.isfile(path): | |
pass | |
else: | |
nuke.message("File was not written. check console for errors") | |
edl_path = nuke.getFilename("Export EDL","*.edl") | |
writeEDL(edl_path,OUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment