PeelCapture exposes the take table to python as a Qt model that can be connected to UI’s, databases or data export systems.
To access the model use:
from PeelApp import cmd
model = cmd.getTakeModel()
The model exposes the columns used in the main ui accessable via the data() method. Model signals can be used to get notifications of changes to the model, e.g. dataChanged() will signal that something has changed in the table. See Qt’s QAbstractItemModel for more signals / slots that are available.
The columns are:
0 - Take
1 - Description
2 - Notes
3 - Start Timecode
4 - End Timecode
5 - Duration
6 - Info
7 - Select
8 - User
9 - Take Number
10 - Take Id
Also the following data is available via UserRoles on column 0:
Qt::UserRole + 0 - UUID
Qt::UserRole + 1 - Shot Name
Qt::UserRole + 2 - Start Timecode
Qt::UserRole + 3 - Start End Timecode
Qt::UserRole + 4 - Start Timecode B
Qt::UserRole + 5 - End Timecode B
Qt::UserRole + 6 - Original Name
Qt::UserRole + 8 - Files
There is also a “Take” object available. This is used internally to store the data. Access to this data should be done through the model, write access in particular, so the change signals are emitted.
To access the internal take data:
from PeelApp import cmd
model = cmd.getTakeModel()
for row in range(model.rowCount()):
take = model.getTake(row)
print(take)
The take object has the following properties and methods:
QUuid uuid; // - UserRole
QString shotName; // - UserRole + 1
QString takeName; // 0
QString description; // 1
QString notes; // 2
TCValue startA; // - UserRole + 2
TCValue endA; // - UserRole + 3
TCValue startB; // - UserRole + 4
TCValue endB; // - UserRole + 5
QString info; // 6 (read only - generated)
QString select; // 7
QString userData; // 8
int take; // 9
int id; // 10
QString origName; // - UserRole + 6
//! Mark name, timecode value(string)
QList<QPair<QString, QString> > marks;
//! Custom meta name = values
QList<QPair<QString, QString> > customItems;
//! Capture Subject, Character
QList<QPair<QString, QString> > subjects;
//! Rigidbody, Prop
QList<QPair<QString, QString> > props;
// UserRole + 8 TODO
//! List of device id's that have a file for this take
QList<int> deviceFiles;
//! True if the take is the current pending (next) take
bool isPending{ false };
};
Here is an example of writing all of the take data to a csv file that can be saved to userPython\peel_user_startup.py . This example includes adding a menu item to the main applications File menu.
from PySide6.QtWidgets import QMenu, QFileDialog, QMessageBox
from PeelApp import cmd
def save_csv(path):
model = cmd.getTakeModel()
import csv
data = []
for row in range(model.rowCount()):
take = model.getTake(row)
if take.isPending:
continue
# timecode is a special class in the Take, so we need to get it via the model
startA = model.data(model.index(row, 2))
endA = model.data(model.index(row, 3))
# convert the QUuid to a string
uuid = take.uuid.toString()
# Convert the marks to a single string
marks = " ".join([ f"{a}:{b}" for a, b in take.marks ])
data.append( [uuid, take.shotName, take.takeName, take.description, take.notes, marks,
startA, endA, take.info, take.select, take.userData, take.take, take.id, take.origName] )
with open(path, "w" , newline="") as fp:
writer = csv.writer(fp)
writer.writerows(data)
def file_menu():
mw = cmd.getMainWindow()
menu = mw.menuBar()
for item in menu.children():
if isinstance(item, QMenu):
if item.objectName() == "menuFile":
return item
def handle_save_csv():
mw = cmd.getMainWindow()
name, filter = QFileDialog.getSaveFileName(mw, "Title")
if name:
save_csv(name)
QMessageBox.information(mw, "CSV", "File saved")
def startup():
fm = file_menu()
action = fm.addAction("Save Extended CSV")
action.triggered.connect(handle_save_csv)
