batch_add_elements
Add multiple nodes and edges to a draw.io diagram in one operation, reducing file reads and writes for efficient diagram construction.
Instructions
Add multiple nodes and edges to a draw.io diagram in a single operation. Much more efficient than calling add_node/add_edge individually — performs only one file read and one file write regardless of how many elements are added. Use this for building entire diagrams or adding multiple components at once.
LAYOUT BEST PRACTICES:
Space nodes at least 200px apart horizontally and 150px vertically to leave room for edge labels.
Use "curved" edgeStyle when multiple edges connect the same nodes or cross over each other.
Use exitPoint/entryPoint (e.g. "left", "right", "topLeft25", "bottomRight75") to separate parallel edges.
For bidirectional pairs, use offset connection points so the two arrows don't overlap.
All edge labels automatically get a white background for readability.
Prefer "orthogonal" for structured layouts and "curved" for organic/many-connection layouts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| edges | No | Array of edges to add | |
| nodes | No | Array of nodes to add | |
| layout | No | Auto-layout mode. "snake" arranges nodes in boustrophedon (row 1: L→R, row 2: R→L) so edges between consecutive rows are short vertical drops instead of spanning the full width. | |
| filePath | Yes | Path to the .drawio file | |
| snakeOptions | No | Options for snake layout (only used when layout="snake") |