Created
October 29, 2018 04:27
-
-
Save kohyuk91/01864cd70ed5ba786c8e1fc0e7922de3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ## | |
| ## Script: import_ZLOC_from_txt_for_PFTrack.py v1.0 | |
| ## | |
| ## Author: Hyuk Ko | |
| ## [email protected] | |
| ## | |
| ## Date: 2018/10/19 | |
| ## | |
| ## Description: Imports 'User Tracks' from ZLOC txt file. | |
| ## | |
| ## Usage: 1.Add this node to 'User Track' node | |
| ## 2.Input Offset Value and Press Enter | |
| ## 3.Browse ZLOC txt file and Press Enter | |
| import pfpy | |
| from pfpy import Tracker, Clip | |
| def pfNodeName(): | |
| return 'Import_ZLOC_from_TXT' | |
| def pfNodeTopLevelButton(): | |
| return 1 | |
| def pfAutoRun(): | |
| return False | |
| def main(): | |
| ############################ Fix Offset Value according to 'In Point'. | |
| offset = int(raw_input()) # Sequence Start with 0001 => offset = 0 | |
| ############################ Sequence Start with 1001 => offset = 1000 | |
| ############################ | |
| path = str(raw_input()) | |
| ############################ | |
| c = pfpy.getClipRef(0) | |
| width = c.getFrameWidth() | |
| height = c.getFrameHeight() | |
| inPoint = c.getInPoint() | |
| outPoint = c.getOutPoint() | |
| clipLen = outPoint - inPoint + 1 | |
| rawList = [] | |
| with open(path,'r') as f: | |
| rawList = [word for line in f for word in line.split()] | |
| zlocNameList = sorted(set(rawList[0::4]), key=rawList.index) | |
| groupByFourList = [rawList[i:i+4] for i in range(0, len(rawList), 4)] | |
| for zlocName in zlocNameList: | |
| t = Tracker.new(zlocName) | |
| for i in range(len(groupByFourList)): | |
| if groupByFourList[i][0] == zlocName: | |
| t.setTrackPosition(int(groupByFourList[i][1])+offset, (float(groupByFourList[i][2])+1)/2 * width-0.5, (float(groupByFourList[i][3])-1)/-2 * height-0.5) | |
| for j in range(clipLen): | |
| if t.getTrackPosition(j+inPoint)[0] == -1920.50 and t.getTrackPosition(j+inPoint)[1] == -1080.50: | |
| t.setHidden(j+inPoint, True) | |
| t.setKeyed(j+inPoint, False) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment