add_elements
Add multiple SVG elements—shapes, text, paths, or images—to an Inkscape SVG document in one call and get their new IDs.
Instructions
Add one or more elements in a single call. Returns the new ids.
Element spec keys — common: type, id, label, layer (name; created if missing), parent (group id), transform, style (css string or dict). Style shorthands: fill, stroke, stroke_width, opacity, fill_opacity, stroke_opacity, stroke_dasharray, stroke_linecap, stroke_linejoin, font_size, font_family, font_weight, font_style, text_anchor. Geometry per type: rect: x, y, width, height, rx, ry, fit_to, fit_padding, fit; circle: cx, cy, r; ellipse: cx, cy, rx, ry; line: x1, y1, x2, y2, marker_start, marker_end; polyline: points, marker_start, marker_end; polygon: points; path: d, marker_start, marker_end; text: x, y, text, line_height, vertical_anchor, width, halo, halo_width; group: -; arrow: x1, y1, x2, y2, shaft_width, head_width, head_length; image: x, y, width, height, href, object_fit, embed; use: x, y, width, height, href. points = [[x,y],...]. text supports '\n' for multiple lines; font_size is in user units. Coordinates are in the parent's system: inside a transformed layer or group (e.g. after layout moved it, or a scaled plan group) they are offset/scaled with it. use: href "symbol_id" places a symbol (or any element) of this document; "library.svg#symbol_id" copies that symbol from a file first (list a library's symbols: document_open it, inspect find {"type": "symbol"}); width/height scale a symbol that has a viewBox. clip: an element id (its current shape) or [x, y, w, h] — the element is cut to it and the clip then moves with the element; null removes it. text halo: '#ffffff' outlines the glyphs behind the fill so text reads over lines (halo_width default 0.3 x font size; 'none' removes). place: {"below": id, "gap": 1.5} (or above / left_of / right_of; "align": start|center|end on the other axis) puts the element beside the MEASURED box of another (real glyph extents, any script) and keeps it there when that element changes; inside repeat, ids are template names; null frees it. Responses warn about overlaps among the touched elements: text on text, text across a shape's edge, text crossed by a line (a text with a halo may cross lines). rect fit_to: [ids] sizes the rect around them after wrapping (fit_padding: n | [v, h] | [t, r, b, l]; fit: both | height | width, e.g. height keeps a card's width); it re-fits when those elements are edited (update_elements {"id": rect} re-fits after moves; fit_to: null frees it).
defaults is merged into every element (only keys valid for its type), e.g. {"font_size": 2.2, "fill": "#2a8a4a", "layer": "Labels"}.
elements_path: a JSON file (a list of specs, or {"elements": [...], "defaults": {...}}) instead of elements — for generated geometry, so it never passes through the conversation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | No | ||
| preview | No | ||
| defaults | No | ||
| elements | No | ||
| elements_path | No |