Skip to content

Commit a6795c0

Browse files
author
Roberto De Ioris
committed
added preliminary version of blueprint_add_member_variable()
1 parent 466503f commit a6795c0

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎Source/UnrealEnginePython/Private/UEPyEditor.cpp‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Editor/ContentBrowser/Public/ContentBrowserModule.h"
1010
#include "UnrealEd.h"
1111
#include "FbxMeshUtils.h"
12+
#include "Kismet2/BlueprintEditorUtils.h"
1213

1314

1415

@@ -537,5 +538,39 @@ PyObject *py_unreal_engine_add_components_to_blueprint(PyObject * self, PyObject
537538

538539
}
539540

541+
PyObject *py_unreal_engine_blueprint_add_member_variable(PyObject * self, PyObject * args) {
542+
543+
PyObject *py_blueprint;
544+
char *name;
545+
char *in_type;
546+
PyObject *py_is_array = nullptr;
547+
if (!PyArg_ParseTuple(args, "Oss|O:blueprint_add_member_variable", &py_blueprint, &name, &in_type, &py_is_array)) {
548+
return NULL;
549+
}
550+
551+
if (!ue_is_pyuobject(py_blueprint)) {
552+
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
553+
}
554+
555+
ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint;
556+
if (!py_obj->ue_object->IsA<UBlueprint>())
557+
return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint");
558+
UBlueprint *bp = (UBlueprint *)py_obj->ue_object;
559+
560+
bool is_array = false;
561+
if (py_is_array && PyObject_IsTrue(py_is_array))
562+
is_array = true;
563+
564+
FEdGraphPinType pin(UTF8_TO_TCHAR(in_type), FString(""), nullptr, is_array, false);
565+
566+
if (FBlueprintEditorUtils::AddMemberVariable(bp, UTF8_TO_TCHAR(name), pin)) {
567+
Py_INCREF(Py_True);
568+
return Py_True;
569+
}
570+
571+
Py_INCREF(Py_False);
572+
return Py_False;
573+
}
574+
540575
#endif
541576

‎Source/UnrealEnginePython/Private/UEPyEditor.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ PyObject *py_unreal_engine_replace_blueprint(PyObject *, PyObject *);
2525
PyObject *py_unreal_engine_create_blueprint_from_actor(PyObject *, PyObject *);
2626
PyObject *py_unreal_engine_add_components_to_blueprint(PyObject *, PyObject *);
2727

28+
PyObject *py_unreal_engine_blueprint_add_member_variable(PyObject *, PyObject *);
29+
2830
#endif

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static PyMethodDef unreal_engine_methods[] = {
111111
{ "replace_blueprint", py_unreal_engine_replace_blueprint, METH_VARARGS, "" },
112112
{ "reload_blueprint", py_unreal_engine_reload_blueprint, METH_VARARGS, "" },
113113
{ "compile_blueprint", py_unreal_engine_compile_blueprint, METH_VARARGS, "" },
114+
{ "blueprint_add_member_variable", py_unreal_engine_blueprint_add_member_variable, METH_VARARGS, "" },
114115
{ "add_components_to_blueprint", py_unreal_engine_add_components_to_blueprint, METH_VARARGS, "" },
115116
{ "message_dialog_open", py_unreal_engine_message_dialog_open, METH_VARARGS, "" },
116117
{ "set_fbx_import_option", py_unreal_engine_set_fbx_import_option, METH_VARARGS, "" },

‎Source/UnrealEnginePython/UnrealEnginePython.Build.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public UnrealEnginePython(TargetInfo Target)
7272
if (UEBuildConfiguration.bBuildEditor)
7373
{
7474
PrivateDependencyModuleNames.AddRange(new string[]{
75-
"UnrealEd"
75+
"UnrealEd",
7676
});
7777
}
7878

0 commit comments

Comments
 (0)