Automation API
Drive Vellum programmatically for testing and scripting.
Vellum exposes a browser automation surface for QA and scripting through window.__vellumRobot.
Inspecting the scene
// List every entity currently in the scene
const entities = window.__vellumRobot.getEntities()
// Validate geometry consistency
const result = window.__vellumRobot.validateScene()Drawing
For user-visible drawing, pass an animateMs of at least 200 so entities don't appear instantly, and await each draw command before starting the next.
Dimension labels
drawDimension and modifyEntity accept a text label template. {measurement} is replaced by the live measured value every time the label is drawn, so it keeps updating when the endpoints move, the scale changes, or units change. Everything around the token is literal, \n starts a new line, {value} is an alias, and {{ / }} are literal braces. Pass "" to restore the default measurement-only label. Reading a dimension back returns the same template string, not the resolved value.
await window.__vellumRobot.drawDimension({
start: { x: 100, y: 600 },
end: { x: 400, y: 600 },
text: "SPAN LENGTH: {measurement}\n(TYP. OF 3)",
animateMs: 300,
})Hatch fills
Closed shapes (drawRectangle, drawEllipse, drawCloud) accept a fillPattern: none, solid, diagonal-45, diagonal-135, crosshatch, grid, or dots. Hatch lines render even with no solid fill; line color defaults to stroke unless patternColor is set. Tune with patternScale, patternRotation, patternLineWidth (0 = hairline), and patternOpacity (0–100).
await window.__vellumRobot.drawRectangle({
x: 0, y: 0, width: 100, height: 60,
stroke: "#1f6feb",
fillPattern: "crosshatch",
patternColor: "#1f6feb",
patternScale: 1.5,
animateMs: 200,
})Exporting
exportPdf({ mode, filename, download }) drives the real server export engine: it flushes pending edits, pins the snapshot revision, and downloads the PDF. mode is flatten (default) or editable. Requires a saved document (a documentId); it returns { ok, byteLength, filename, revision } or an error explaining what's missing.
// Draw, then export to PDF (download to disk)
await window.__vellumRobot.drawRectangle({ x: 0, y: 0, width: 80, height: 50, fillPattern: "dots" })
const res = await window.__vellumRobot.exportPdf({ mode: "flatten" })
// res => { ok: true, byteLength, filename, revision, downloaded: true }UI hooks
Interactive elements expose data-robot selectors for reliable targeting:
tool-*— select a tool (e.g.tool-select,tool-polyline).zoom-*— zoom controls.page-*— page navigation controls.export— the export control.canvas— the drawing surface.
There's no direct drawOffset command — drive the real offset UI flow instead. Verify outcomes with getEntities() or validateScene().