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,
})

Scales, counts and angles

Every sheet has its own scale. getScale({ page, point }) reports the scale at a point (a viewport's, when the point is inside one), and setScale("1\"=20'", { page, applyTo }) sets a sheet's scale, or every sheet's with applyTo: "all". addViewport, listViewports and removeViewport manage viewports, with an optional verticalScale for profiles. drawCount places numbered count marks, one per point, and drawAngle places an angle from a point on each arm and the vertex; measureEntity(id).angleDeg reads an angle back.

await window.__vellumRobot.drawCount({ points: [{ x: 120, y: 300 }, { x: 180, y: 300 }], name: "Sewer manholes", animateMs: 300 })
await window.__vellumRobot.drawAngle({ a: { x: 400, y: 300 }, vertex: { x: 300, y: 300 }, b: { x: 300, y: 400 }, animateMs: 300 })
window.__vellumRobot.addViewport({ page: 3, x: 200, y: 1550, width: 900, height: 1150, name: "Profile", scale: "1\"=20'", verticalScale: "1\"=2'" })

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). Dimension, Area, Angle and Count share the Measure button, tool-measure-group, which starts the tool it shows; its caret tool-variants-measure opens the menu whose tool-measure, tool-area, tool-angle and tool-count items exist only while it is open, so the M, A, Y and D keys are simpler to drive.
  • zoom-* — zoom controls.
  • page-* — page navigation controls.
  • export — the export control.
  • canvas — the drawing surface.
Note

There's no direct drawOffset command — drive the real offset UI flow instead. Verify outcomes with getEntities() or validateScene().