vi_edit
Edits an existing LabVIEW VI by removing nodes, adding code, and rewiring existing objects and loop or case contents while preserving diagram layout; backs up and reverts broken edits.
Instructions
Change an existing VI: remove nodes, add code, and wire it to what is already there, including inside existing loops and case frames. The rest of the diagram keeps its layout. Call vi_dump first to get node ids.
spec = the vi_create spec plus: "remove": ["increment_4", ...] vi_dump node ids to delete, with their wires "existing": {spec name: what} objects already in the VI that the spec refers to: "Gain" a front-panel control/indicator by label {"node": "multiply_7"} a vi_dump node (function, subVI, constant, loop, case) {"node": "for_loop_3", "functions": [...], ...} new code inside an existing loop {"node": "case_structure_5", "cases": {"1": {...}}} new code inside case frame 1 {"node": "for_loop_3", "shift_registers": ["acc"], ...} new shift registers on a loop (wire "acc.left" / "acc.right" like in vi_create) {"node": "case_structure_5", "remove_cases": [2], "add_cases": [{"value": 5, "outputs": {"tunnel_9": "five"}, ...contents}, {"value": "7..9", "default": true}]} remove frames (by index) and add frames (value, range or string as the selector takes); "outputs" gives the new frame's value for existing output tunnels (vi_dump tunnel ids) "move": {"for_loop_3": [300, 200]} move block-diagram objects "rename": {"Gain": "Gain (dB)"} relabel front-panel controls/indicators "values": {"Gain": 2.5, "constant_6": 10} a control's default value (by label) or a constant's value (vi_dump id) "retype": {"Count": "i32", "constant_6": "u8"} change a number's type (control or constant) "disconnect": ["out_12", "multiply_7.x"] cut the wire into these vi_dump wire ends (a wire's other branches stay); then wire a new source in "wires": {"disconnect": ["x2_5"], "existing": {"a": {"node": "add_8"}, "o": "x2"}, "wires": [["a.x+y", "o"]]} Existing nodes are wired like new ones ("m.x", "L.i", "C.selector"). Code put in a case frame may only be wired to code in that frame and to existing objects; crossing the border makes a tunnel. Example, replace out = x + 1 with out = x * 3: {"remove": ["increment_4"], "existing": {"x": "x", "o": "out"}, "constants": [{"name": "k", "type": "dbl", "value": 3}], "functions": [{"name": "m", "function": "Multiply"}], "wires": [["x", "m.x"], ["k", "m.y"], ["m.x*y", "o"]]} An input that is already wired cannot take a second source (remove its node first). New controls stay off the connector pane unless they set "connector". rewire=true deletes with LabVIEW's Quick Drop "Remove and Rewire" (joins loose ends of matching type) instead. A copy is saved to .lvmcp-backup/ next to the VI first (backup=false skips it). If the edit leaves the VI broken, or a requested wire could not be made, the VI is reverted and not saved (allow_broken=true saves a broken result anyway).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "<path>",
"spec": "<spec>"
},
"name": "vi_edit"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| spec | Yes | ||
| backup | No | ||
| rewire | No | ||
| allow_broken | No |