Layout
bpmn-cli draws the diagram for you. You change the picture by naming elements, never coordinates.
How a write draws
- A drawing is kept. Untouched shapes and lines stay where they are; a new element goes next to its neighbours, and only what follows it moves right to make room. A drawing someone formatted by hand stays as it is.
- An empty drawing is drawn in full, as is a file without one.
bpmn layoutredraws everything. Colours and DI ids stay, positions do not. Use it to finish a model built from scratch over several writes, or when a change answersE_LAYOUT_INCREMENTAL(no room found; nothing was written). In a batch, alayoutoperation at the end does the same.
Every write prints the layout score before and after. Lower is better, 0 means no crossings, overlaps or labels on lines. bpmn diagram <file> lists the problems with their ids, and bpmn render <file> --problems -o out.svg numbers them in the picture.
add ... --after userTask_checkInvoice: the drawing is kept and room is madebpmn layout: redrawn in the engine's own orderFix a spot
These commands change only the drawing. In a batch they come after the model operations.
| command | effect |
|---|---|
place <ids...> --row-of|--below|--above <id> and/or --column-of|--after|--before <id> | move shapes as a group onto another element's row or column |
place <boundaryEventId> --side top|bottom | move a boundary event to the other border |
color <ids...> --color blue|orange|green|red|purple|default | colour shapes; default removes it |
label <id> --side above|below|left|right | move a label |
route <flowId> [--exit <side>] [--entry <side>] | route one flow again |
space --after|--below <id> [--by column|row|<n>col|<px>] | make room; a negative amount closes it |
tidy [<ids...>] | remove overlaps with minimal moves |
compact [<frameIds...>] | close empty rows and columns, shrink frames to their content |
order <id> <ids...> | order a gateway's branches, a pool's lanes or the pools |
place and color also take --path <fromId> <toId> (the nodes on the shortest path) or --branch <flowId> (what only that branch reaches) instead of ids. A shape never leaves its lane or pool (E_LEAVES_CONTAINER: move <id> --lane <laneId> first). When there is no room, E_NO_ROOM carries the bpmn space command that makes it.
Example: resolve a crossing
$ bpmn diagram order.bpmn
score 6: crossings 1, labelOnLine 1
crossings flow_invoiceOkToBookInvoice x messageFlow_askCustomerToCustomer
labelOnLine flow_invoiceOkToBookInvoice, messageFlow_askCustomerToCustomer
participant participant_customer "Customer" c0..c5
participant participant_orderHandling "Order handling" c0..c5 row 1: c0 startEvent_orderReceived, c1 userTask_checkInvoice, c2 gateway_invoiceOk, c3 serviceTask_bookInvoice, c4 gateway_invoiceOkJoin, c5 endEvent_invoiceHandled
row 2: c3 sendTask_askCustomer
$ bpmn place order.bpmn sendTask_askCustomer --row-of userTask_checkInvoice
...
layout quality: score 6 -> 0; resolved: crossings flow_invoiceOkToBookInvoice x messageFlow_askCustomerToCustomer, labelOnLine flow_invoiceOkToBookInvoice x messageFlow_askCustomerToCustomer
written: order.bpmnrender --problems: score 6place ... --row-of userTask_checkInvoice: score 0What the engine draws
So you can predict the picture from the model:
- Left to right. At a split the default flow runs straight on, else the first flow; the other branches go alternately below and above it.
bpmn orderchanges the order,set <flowId> default=truepicks the straight one. - Boundary events sit on the host's bottom border first, their path below. Loops run underneath.
- Sub-processes are expanded and laid out inside; event sub-processes go below the content.
- Annotations go above their element, data below. Pools stack vertically, message flows run between them.
- Gateway names sit above, event names below, flow names above the flow.
- A new shape gets the bpmn-js size (task 100 by 80, gateway 50 by 50, event 36 by 36); a long name wraps inside it.