Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## This should be pasted into the Python node in SOPs
- ## Add two interface parameters - "txt" of type File and "framerate" of type int
- ## This script is parsing a marker list from Adobe Premiere Pro. It should be saved as CSV file and next resaved with UTF-8
- ## On the output it creates a number of points equal to number of markers.
- ## Each point has attribute start as marker start (in frames) and end as marker end (in frames)
- import hou
- import string
- node = hou.pwd()
- geo = node.geometry()
- fileParm = node.parm("txt").evalAsString()
- framerate = node.parm("framerate").eval()
- def timecode_to_frames(timecode):
- return sum(f * int(t) for f,t in zip((3600*framerate, 60*framerate, framerate, 1), timecode.split(':')))
- with open(fileParm, 'r') as f:
- lines = f.read().splitlines() # Read lines
- f.close()
- Attribstart = geo.addAttrib(hou.attribType.Point, "start", 0)
- Attribend = geo.addAttrib(hou.attribType.Point, "end", 0)
- lines.pop(0) ## delete first line (text)
- current=0
- for line in lines:
- times=line.split(chr(9))
- current=0
- for time in times:
- if len(time)>0:
- if time[0].isdigit():
- if current==0:
- pt=geo.createPoint()
- pt.setAttribValue(Attribstart, timecode_to_frames(time))
- if current==1:
- pt.setAttribValue(Attribend, timecode_to_frames(time))
- current=(current+1)%3
Advertisement
Add Comment
Please, Sign In to add comment