I wanted to know whether there’s an automated way to export the frame numbers wherever there is a time marker in the takes in a FBX file and then input those values in a designated excel sheet?
It would be great if someone could give some insight about this topic!
The script saves time marks info from current take to .json file.
To export this data to excel sheets, I would first try to modify the script, so it will automatically copy all data to clipboard instead of json file, so it would be easy to paste them manually into excel table.
It would be also easy to modify it, so it would export time marks from all takes.
I can help you, depending what you exactly need
import json
from pyfbsdk import FBSystem
currentTake = FBSystem().CurrentTake
marksList = dict()
for i in range(currentTake.GetTimeMarkCount()):
markFrame = str(currentTake.GetTimeMarkTime(i).GetFrame())
markName = currentTake.GetTimeMarkName(i)
marksList[str(i)] = {'frame': markFrame, 'name': markName }
with open("D:\\marks_list.json", 'w+') as outfile:
str_ = json.dumps(marksList, indent=3,sort_keys=True)
outfile.write(str_)
I found a workflow that worked for me.
Here’s the python snippet:
import csv
from pyfbsdk import FBSystem
system = FBSystem()
scene = system.Scene
csv_file_path = "output.csv"
# Open the CSV file in write mode
with open(csv_file_path, mode='w', newline='') as csv_file:
csv_writer = csv.writer(csv_file)
# Write header
csv_writer.writerow(["TAKE NAME", "MARKER ONE", "MARKER TWO"])
# Iterate through all takes
for take in scene.Takes:
frame_number_1 = take.GetTimeMarkTime(0).GetFrame()/30
frame_number_2 = take.GetTimeMarkTime(1).GetFrame()/30
csv_writer.writerow([take.Name, frame_number_1, frame_number_2])
print("Data exported to {csv_file_path}")
NOTE:
This exports a csv file in the same path as this particular script is saved. The path can be customized in the csv_file_path line.
The data can then be imported from the csv file into any Excel worksheet!
Here, I needed only two time marker data for each take. But that can be easily changed as per requirements.
Any ideas to improve and extend this script are welcome!
Hey there, thank you for your reply.
I was trying out on my own at work today and came up with a similar solution slightly tweaked as per my requirements.
Copying the data to Clipboard is also a neat idea!
Thanks again!