Skip to content

Commit 15f9eea

Browse files
Add remove_component_from_blueprint
Add support for removing components from blueprints to compliment existing add component functionality
1 parent b36a654 commit 15f9eea

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Source/UnrealEnginePython/Private/UEPyEditor.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,37 @@ PyObject *py_unreal_engine_get_blueprint_components(PyObject * self, PyObject *
14731473

14741474
}
14751475

1476+
PyObject *py_unreal_engine_remove_component_from_blueprint(PyObject *self, PyObject *args)
1477+
{
1478+
PyObject *py_blueprint;
1479+
char *name;
1480+
char *parentName = nullptr;
1481+
1482+
if (!PyArg_ParseTuple(args, "Os|s:remove_component_from_blueprint", &py_blueprint, &name, &parentName))
1483+
{
1484+
return NULL;
1485+
}
1486+
1487+
if (!ue_is_pyuobject(py_blueprint))
1488+
{
1489+
return PyErr_Format(PyExc_Exception, "argument is not a UObject");
1490+
}
1491+
1492+
ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint;
1493+
if (!py_obj->ue_object->IsA<UBlueprint>())
1494+
return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint");
1495+
UBlueprint *bp = (UBlueprint *)py_obj->ue_object;
1496+
1497+
bp->Modify();
1498+
USCS_Node *ComponentNode = bp->SimpleConstructionScript->FindSCSNode(UTF8_TO_TCHAR(name));
1499+
if (ComponentNode)
1500+
{
1501+
bp->SimpleConstructionScript->RemoveNode(ComponentNode);
1502+
}
1503+
1504+
Py_RETURN_NONE;
1505+
}
1506+
14761507
PyObject *py_unreal_engine_add_component_to_blueprint(PyObject * self, PyObject * args)
14771508
{
14781509

Source/UnrealEnginePython/Private/UEPyEditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ PyObject *py_unreal_engine_reload_blueprint(PyObject *, PyObject *);
5252
PyObject *py_unreal_engine_replace_blueprint(PyObject *, PyObject *);
5353
PyObject *py_unreal_engine_create_blueprint_from_actor(PyObject *, PyObject *);
5454
PyObject *py_unreal_engine_add_component_to_blueprint(PyObject *, PyObject *);
55+
PyObject *py_unreal_engine_remove_component_from_blueprint(PyObject *, PyObject *);
5556

5657
PyObject *py_unreal_engine_blueprint_add_member_variable(PyObject *, PyObject *);
5758
PyObject *py_unreal_engine_blueprint_add_new_timeline(PyObject *, PyObject *);

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ static PyMethodDef unreal_engine_methods[] = {
389389
{ "blueprint_get_all_graphs", py_unreal_engine_blueprint_get_all_graphs, METH_VARARGS, "" },
390390
{ "blueprint_mark_as_structurally_modified", py_unreal_engine_blueprint_mark_as_structurally_modified, METH_VARARGS, "" },
391391
{ "add_component_to_blueprint", py_unreal_engine_add_component_to_blueprint, METH_VARARGS, "" },
392+
{ "remove_component_from_blueprint", py_unreal_engine_remove_component_from_blueprint, METH_VARARGS, "" },
392393
{ "get_blueprint_components", py_unreal_engine_get_blueprint_components, METH_VARARGS, "" },
393394
{ "create_material_instance", py_unreal_engine_create_material_instance, METH_VARARGS, "" },
394395
{ "message_dialog_open", py_unreal_engine_message_dialog_open, METH_VARARGS, "" },

0 commit comments

Comments
 (0)