Skip to content

Commit 03ac161

Browse files
author
Roberto De Ioris
committed
added blueprint_add_function
1 parent 32156d7 commit 03ac161

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyEditor.cpp‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,30 @@ PyObject *py_unreal_engine_blueprint_add_new_timeline(PyObject * self, PyObject
831831
return (PyObject *)ret;
832832
}
833833

834+
PyObject *py_unreal_engine_blueprint_add_function(PyObject * self, PyObject * args) {
835+
836+
PyObject *py_blueprint;
837+
char *name;
838+
if (!PyArg_ParseTuple(args, "Os:blueprint_add_function", &py_blueprint, &name)) {
839+
return NULL;
840+
}
841+
842+
if (!ue_is_pyuobject(py_blueprint)) {
843+
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
844+
}
845+
846+
ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint;
847+
if (!py_obj->ue_object->IsA<UBlueprint>())
848+
return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint");
849+
UBlueprint *bp = (UBlueprint *)py_obj->ue_object;
850+
851+
UEdGraph *graph = FBlueprintEditorUtils::CreateNewGraph(bp, FName(UTF8_TO_TCHAR(name)), UEdGraph::StaticClass(), UEdGraphSchema_K2::StaticClass());
852+
FBlueprintEditorUtils::AddFunctionGraph<UClass>(bp, graph, true, nullptr);
853+
854+
Py_INCREF(Py_None);
855+
return Py_None;
856+
}
857+
834858
PyObject *py_unreal_engine_editor_on_asset_post_import(PyObject * self, PyObject * args) {
835859
PyObject *py_callable;
836860
if (!PyArg_ParseTuple(args, "O:editor_on_asset_post_import", &py_callable)) {
@@ -1002,7 +1026,7 @@ PyObject *py_unreal_engine_move_selected_actors_to_level(PyObject *self, PyObjec
10021026
}
10031027

10041028
PyObject *py_unreal_engine_editor_take_high_res_screen_shots(PyObject * self, PyObject * args) {
1005-
1029+
10061030
GEditor->TakeHighResScreenShots();
10071031

10081032
Py_INCREF(Py_None);

‎Source/UnrealEnginePython/Private/UEPyEditor.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ PyObject *py_ue_factory_create_new(ue_PyUObject *, PyObject *);
4949

5050
PyObject *py_unreal_engine_editor_take_high_res_screen_shots(PyObject *, PyObject *);
5151

52+
PyObject *py_unreal_engine_blueprint_add_function(PyObject *, PyObject *);
53+
5254
// efeng additional functions
5355
PyObject *py_unreal_engine_create_material_instance(PyObject *, PyObject *);
5456

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ static PyMethodDef unreal_engine_methods[] = {
156156
{ "blueprint_add_member_variable", py_unreal_engine_blueprint_add_member_variable, METH_VARARGS, "" },
157157
{ "blueprint_add_new_timeline", py_unreal_engine_blueprint_add_new_timeline, METH_VARARGS, "" },
158158
{ "blueprint_set_variable_visibility", py_unreal_engine_blueprint_set_variable_visibility, METH_VARARGS, "" },
159+
{ "blueprint_add_function", py_unreal_engine_blueprint_add_function, METH_VARARGS, "" },
159160
{ "add_component_to_blueprint", py_unreal_engine_add_component_to_blueprint, METH_VARARGS, "" },
160161
{ "create_material_instance", py_unreal_engine_create_material_instance, METH_VARARGS, "" },
161162
{ "message_dialog_open", py_unreal_engine_message_dialog_open, METH_VARARGS, "" },

‎Source/UnrealEnginePython/UnrealEnginePython.Build.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public UnrealEnginePython(TargetInfo Target)
8686
{
8787
PrivateDependencyModuleNames.AddRange(new string[]{
8888
"UnrealEd",
89-
"LevelEditor"
89+
"LevelEditor",
90+
"BlueprintGraph"
9091
});
9192
}
9293

0 commit comments

Comments
 (0)