Skip to content

Instantly share code, notes, and snippets.

@kohyuk91
Created October 19, 2018 07:14
Show Gist options
  • Select an option

  • Save kohyuk91/a25bcaaa7ae4a5ebdf0c1f09e5feb255 to your computer and use it in GitHub Desktop.

Select an option

Save kohyuk91/a25bcaaa7ae4a5ebdf0c1f09e5feb255 to your computer and use it in GitHub Desktop.
##
## Script: import_ZLOC_from_clipboard_for_PFTrack.py v1.0
##
## Author: Hyuk Ko
## [email protected]
##
## Date: 2018/10/19
##
## Description: Exports 'User Tracks' to ZLOC file. Saves data to Clipboard.
##
## Usage: 1.Add this node to 'User Track' node
## 2.Input Offset Value and'Run' Script
import pfpy
from pfpy import Tracker, Clip
def pfNodeName():
return 'Import_ZLOC_from_CLIPBOARD'
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
############################
cbText = str(raw_input())
############################
c = pfpy.getClipRef(0)
width = c.getFrameWidth()
height = c.getFrameHeight()
inPoint = c.getInPoint()
outPoint = c.getOutPoint()
clipLen = outPoint - inPoint + 1
rawList = cbText.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