@@ -110,6 +110,74 @@ PyObject *py_ue_graph_add_node_custom_event(ue_PyUObject * self, PyObject * args
110110
111111}
112112
113+ PyObject *py_ue_graph_get_good_place_for_new_node (ue_PyUObject * self, PyObject * args) {
114+
115+ ue_py_check (self);
116+
117+ if (!self->ue_object ->IsA <UEdGraph>()) {
118+ return PyErr_Format (PyExc_Exception, " uobject is not a UEdGraph" );
119+ }
120+
121+ UEdGraph *graph = (UEdGraph *)self->ue_object ;
122+ FVector2D pos = graph->GetGoodPlaceForNewNode ();
123+
124+ PyObject *ret = PyTuple_New (2 );
125+ PyTuple_SetItem (ret, 0 , PyLong_FromDouble (pos.X ));
126+ PyTuple_SetItem (ret, 1 , PyLong_FromDouble (pos.Y ));
127+ return ret;
128+ }
129+
130+ PyObject *py_ue_graph_add_node_event (ue_PyUObject * self, PyObject * args) {
131+
132+ ue_py_check (self);
133+
134+ PyObject *py_class = nullptr ;
135+ char *name = nullptr ;
136+ int x = 0 ;
137+ int y = 0 ;
138+
139+ if (!PyArg_ParseTuple (args, " Os|ii:graph_add_node_event" , &py_class, &name, &x, &y)) {
140+ return NULL ;
141+ }
142+
143+ if (!self->ue_object ->IsA <UEdGraph>()) {
144+ return PyErr_Format (PyExc_Exception, " uobject is not a UEdGraph" );
145+ }
146+
147+ UEdGraph *graph = (UEdGraph *)self->ue_object ;
148+
149+ if (!ue_is_pyuobject (py_class)) {
150+ return PyErr_Format (PyExc_Exception, " argument is not a UObject" );
151+ }
152+
153+ ue_PyUObject *py_obj = (ue_PyUObject *)py_class;
154+ if (!py_obj->ue_object ->IsA <UClass>()) {
155+ return PyErr_Format (PyExc_Exception, " argument is not a UClass" );
156+ }
157+
158+ UClass *u_class = (UClass *)py_obj->ue_object ;
159+ UBlueprint *bp = (UBlueprint *)graph->GetOuter ();
160+
161+ UK2Node_Event *node = FBlueprintEditorUtils::FindOverrideForFunction (bp, u_class, UTF8_TO_TCHAR (name));
162+ if (!node) {
163+ node = NewObject<UK2Node_Event>(graph);
164+
165+ UEdGraphSchema_K2::SetNodeMetaData (node, FNodeMetadata::DefaultGraphNode);
166+ node->EventReference .SetExternalMember (UTF8_TO_TCHAR (name), u_class);
167+ FEdGraphSchemaAction_K2NewNode::SpawnNodeFromTemplate<UK2Node_Event>(graph, node, FVector2D (x, y));
168+ // graph->AddNode(node);
169+ }
170+
171+ FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified (bp);
172+
173+ PyObject *ret = (PyObject *)ue_get_python_wrapper (node);
174+ if (!ret)
175+ return PyErr_Format (PyExc_Exception, " uobject is in invalid state" );
176+ Py_INCREF (ret);
177+ return ret;
178+
179+ }
180+
113181PyObject *py_ue_graph_add_node_variable_get (ue_PyUObject * self, PyObject * args) {
114182
115183 ue_py_check (self);
@@ -142,12 +210,6 @@ PyObject *py_ue_graph_add_node_variable_get(ue_PyUObject * self, PyObject * args
142210
143211 UK2Node_VariableGet *node = NewObject<UK2Node_VariableGet>(graph);
144212
145- node->CreateNewGuid ();
146- node->PostPlacedNewNode ();
147- node->SetFlags (RF_Transactional);
148- node->AllocateDefaultPins ();
149- node->NodePosX = x;
150- node->NodePosY = y;
151213 UEdGraphSchema_K2::ConfigureVarNode (node, FName (UTF8_TO_TCHAR (name)), u_struct, FBlueprintEditorUtils::FindBlueprintForGraph (graph));
152214 UEdGraphSchema_K2::SetNodeMetaData (node, FNodeMetadata::DefaultGraphNode);
153215 FEdGraphSchemaAction_K2NewNode::SpawnNodeFromTemplate<UK2Node_VariableGet>(graph, node, FVector2D (x, y));
@@ -196,12 +258,6 @@ PyObject *py_ue_graph_add_node_variable_set(ue_PyUObject * self, PyObject * args
196258
197259 UK2Node_VariableSet *node = NewObject<UK2Node_VariableSet>(graph);
198260
199- node->CreateNewGuid ();
200- node->PostPlacedNewNode ();
201- node->SetFlags (RF_Transactional);
202- node->AllocateDefaultPins ();
203- node->NodePosX = x;
204- node->NodePosY = y;
205261 UEdGraphSchema_K2::ConfigureVarNode (node, FName (UTF8_TO_TCHAR (name)), u_struct, FBlueprintEditorUtils::FindBlueprintForGraph (graph));
206262 UEdGraphSchema_K2::SetNodeMetaData (node, FNodeMetadata::DefaultGraphNode);
207263 FEdGraphSchemaAction_K2NewNode::SpawnNodeFromTemplate<UK2Node_VariableSet>(graph, node, FVector2D (x, y));
0 commit comments