Skip to content

Commit ee68791

Browse files
author
Roberto De Ioris
committed
improved sequencer api
1 parent 003849b commit ee68791

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
885885
// Sequencer
886886
{ "sequencer_master_tracks", (PyCFunction)py_ue_sequencer_master_tracks, METH_VARARGS, "" },
887887
{ "sequencer_possessable_tracks", (PyCFunction)py_ue_sequencer_possessable_tracks, METH_VARARGS, "" },
888+
{ "sequencer_get_camera_cut_track", (PyCFunction)py_ue_sequencer_get_camera_cut_track, METH_VARARGS, "" },
888889
#if WITH_EDITOR
889890
{ "sequencer_folders", (PyCFunction)py_ue_sequencer_folders, METH_VARARGS, "" },
890891
{ "sequencer_create_folder", (PyCFunction)py_ue_sequencer_create_folder, METH_VARARGS, "" },

Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,39 @@ PyObject *py_ue_sequencer_find_possessable(ue_PyUObject *self, PyObject * args)
121121
ue_py_check(self);
122122

123123
char *guid;
124-
if (!PyArg_ParseTuple(args, "s:sequencer_find_possessable", &guid))
124+
PyObject *py_parent = nullptr;
125+
if (!PyArg_ParseTuple(args, "s|O:sequencer_find_possessable", &guid, &py_parent))
125126
{
126-
return NULL;
127+
return nullptr;
127128
}
128129

129-
if (!self->ue_object->IsA<ULevelSequence>())
130-
return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence");
130+
ULevelSequence *seq = ue_py_check_type<ULevelSequence>(self);
131+
if (!seq)
132+
{
133+
return PyErr_Format(PyExc_Exception, "uobject is not a ULevelSequence");
134+
}
131135

132136
FGuid f_guid;
133137
if (!FGuid::Parse(FString(guid), f_guid))
134138
{
135139
return PyErr_Format(PyExc_Exception, "invalid GUID");
136140
}
137141

138-
ULevelSequence *seq = (ULevelSequence *)self->ue_object;
139-
140142
#if ENGINE_MINOR_VERSION < 15
141143
UObject *u_obj = seq->FindPossessableObject(f_guid, seq);
142144
#else
145+
UObject *parent = nullptr;
146+
if (py_parent)
147+
{
148+
parent = ue_py_check_type<UObject>(py_parent);
149+
if (!parent)
150+
{
151+
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
152+
}
153+
}
143154
UObject *u_obj = nullptr;
144155
TArray<UObject *, TInlineAllocator<1>> u_objects;
145-
seq->LocateBoundObjects(f_guid, nullptr, u_objects);
156+
seq->LocateBoundObjects(f_guid, parent, u_objects);
146157
if (u_objects.Num() > 0)
147158
{
148159
u_obj = u_objects[0];
@@ -152,7 +163,7 @@ PyObject *py_ue_sequencer_find_possessable(ue_PyUObject *self, PyObject * args)
152163
return PyErr_Format(PyExc_Exception, "unable to find uobject with GUID \"%s\"", guid);
153164

154165
Py_RETURN_UOBJECT(u_obj);
155-
}
166+
}
156167

157168
PyObject *py_ue_sequencer_find_spawnable(ue_PyUObject *self, PyObject * args)
158169
{
@@ -273,7 +284,7 @@ PyObject *py_ue_sequencer_add_actor(ue_PyUObject *self, PyObject * args)
273284
}
274285

275286
return PyUnicode_FromString(TCHAR_TO_UTF8(*new_guid.ToString()));
276-
}
287+
}
277288

278289
PyObject *py_ue_sequencer_add_actor_component(ue_PyUObject *self, PyObject * args)
279290
{
@@ -395,6 +406,26 @@ PyObject *py_ue_sequencer_master_tracks(ue_PyUObject *self, PyObject * args)
395406
return py_tracks;
396407
}
397408

409+
PyObject *py_ue_sequencer_get_camera_cut_track(ue_PyUObject *self, PyObject * args)
410+
{
411+
412+
ue_py_check(self);
413+
414+
if (!self->ue_object->IsA<ULevelSequence>())
415+
return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence");
416+
417+
ULevelSequence *seq = (ULevelSequence *)self->ue_object;
418+
UMovieScene *scene = seq->GetMovieScene();
419+
420+
UMovieSceneTrack *track = scene->GetCameraCutTrack();
421+
if (!track)
422+
{
423+
return PyErr_Format(PyExc_Exception, "unable to find camera cut track");
424+
}
425+
426+
Py_RETURN_UOBJECT(track);
427+
}
428+
398429
PyObject *py_ue_sequencer_possessables(ue_PyUObject *self, PyObject * args)
399430
{
400431

Source/UnrealEnginePython/Private/UObject/UEPySequencer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
PyObject *py_ue_sequencer_master_tracks(ue_PyUObject *, PyObject *);
88
PyObject *py_ue_sequencer_possessable_tracks(ue_PyUObject *, PyObject *);
99
PyObject *py_ue_sequencer_track_sections(ue_PyUObject *, PyObject *);
10+
PyObject *py_ue_sequencer_get_camera_cut_track(ue_PyUObject *, PyObject *);
1011
#if WITH_EDITOR
1112
PyObject *py_ue_sequencer_folders(ue_PyUObject *, PyObject *);
1213
PyObject *py_ue_sequencer_create_folder(ue_PyUObject *, PyObject *);

0 commit comments

Comments
 (0)