add_graph_node
Create a single Blueprint event or function graph node and return it with its newly allocated pins, enabling immediate wiring without an extra node lookup.
Instructions
Create ONE node in a Blueprint's event/function graph (node_type selects the kind) and return it WITH its freshly allocated pins, so connect_pins / set_pin_default_value can wire it immediately without a follow-up get_graph_nodes. Use build_blueprint_graph instead when several nodes must be created AND wired in a single undo transaction, and get_function_pins to learn a call_function's pin names BEFORE creating anything. node_type='event' creates a REAL override (the declaring interface/parent class is resolved automatically and bOverrideFunction is set; target_class is ignored here) and fails loudly for a name that is not an overridable event -- an interface method WITH a return value is not an event, use implement_interface_function.
Returns: { node_id, class, title, pos_x, pos_y, comment, pins:[{name, direction:'input'|'output', type, linked_to, default}], blueprint_name, graph_name } -- the created node WITH its freshly-allocated pins. The pin names are already here, so you can wire the node via connect_pins/set_pin_default_value WITHOUT a follow-up get_graph_nodes. Read "class" as a sanity check: a node_type that was expected to produce an async/latent node and comes back as "K2Node_CallFunction" is a mute no-op that still compiles 0/0.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cases | No | Optional string array of case pins for switch_int/switch_string/switch_name | |
| force | No | Optional. This command is REFUSED while a Play-in-Editor session is running: it either compiles a Blueprint (the reinstancer can retain a world, and CheckForWorldGCLeaks is Fatal -- it KILLS the editor) or writes to disk (Editor.AllowSavingAssetsDuringPIE=0 makes the engine refuse the write, so it would report success without writing a byte). Stop PIE and retry instead; force=true runs it anyway, at your own risk. | |
| scope | No | Optional scope hint for variable_get/variable_set: 'auto' (default; a function-local variable declared in the target graph wins, else a self/member variable), 'local' (function-local variable ONLY), or 'member' (member variable only -- self, or on target_class when supplied). Ignored by other node types. | |
| arguments | No | Optional string array of argument names for format_text | |
| enum_path | Yes | Enum path or name; required for switch_enum and enum_literal nodes | |
| node_type | Yes | One of event, custom_event, call_function, print_string, variable_get, variable_set, branch, sequence, self, cast, spawn_actor (alias spawn_actor_from_class), create_widget, make_struct, break_struct, get_array_item, select, make_array, make_set, make_map, switch_int, switch_string, switch_name, switch_enum, enum_literal, format_text, foreach, foreach_with_break, do_once, gate, flipflop, for_loop, while_loop, is_valid, add_delegate, macro_instance | |
| dispatcher | Yes | Event-dispatcher (multicast delegate) name; required for add_delegate node type. Must already exist in the COMPILED class (add_event_dispatcher + compile_blueprint), and it binds on self only -- for a dispatcher on another class use add_object_bound_event. | |
| event_name | Yes | Event name; required for event and custom_event node types | |
| graph_name | No | Target graph name; defaults to the Blueprint's event graph when omitted | |
| num_inputs | No | Optional input-pin count for make_array/make_set/make_map (added after spawn) | |
| position_x | No | Node X position on the graph canvas (ignored when node_position is set) | |
| position_y | No | Node Y position on the graph canvas (ignored when node_position is set) | |
| struct_type | Yes | Struct type; required for make_struct and break_struct nodes | |
| macro_source | No | Set to "standard_macros" to skip this Blueprint's own MacroGraphs and resolve macro_graph_name only in the engine StandardMacros library. Only read for node_type=macro_instance. | |
| target_class | Yes | Class owning the function or cast/spawn target class. For variable_get/variable_set it names the class that owns the variable, producing a non-self member-access node (with a 'target' pin) instead of a self-context node. For create_widget it names the widget class to construct (e.g. WBP_Foo_C, a full asset path, or the widget Blueprint short name); the node exposes that widget's Expose-On-Spawn pins. | |
| function_name | Yes | Function to call; required for call_function node type | |
| node_position | No | Node canvas position as [x, y]; takes precedence over position_x/position_y | |
| variable_name | Yes | Variable to get/set; required for variable_get and variable_set | |
| blueprint_name | No | Blueprint name (resolved under /Game/Blueprints) or full asset path. Pass the FULL path when the short name is ambiguous: a bare name that matches two assets resolves to one of them silently. | |
| blueprint_path | No | Alias of `blueprint_name` (same value, same meaning). Accepted because sibling tools spell this parameter differently; prefer `blueprint_name`. | |
| macro_graph_name | Yes | Macro graph name; required for node_type=macro_instance. Resolved against this Blueprint's own MacroGraphs first, then the engine StandardMacros. |