Nodus Draw: Command line

The desktop application can convert drawings from a command prompt or a script, without opening a window: to make PNGs, PDFs or plain SVGs from your drawings, or to turn diagrams written as text (Mermaid, PlantUML, WaveDrom) into drawings. It reads every kind of file Nodus Draw opens, and makes the same files as File › Export and File › Save.

nodus-cmd convert drawing.svg drawing.png

nodus-cmd is in the folder Nodus Draw is installed in: nodus-cmd.cmd on Windows (next to nodus.exe), nodus-cmd on Linux. Add that folder to your PATH, or type its full path. On Linux nodus convert … works too. It waits until the files are made, and its exit code says how it went.

Inputs and outputs

The first file named is the drawing to convert; the files after it are the ones to make. Each file's format comes from its name:

Name ends Makes
.svg or .nodus.svg a Nodus drawing (SVG), as File › Save
.plain.svg a plain SVG, for other programs
.png a picture
.pdf a PDF
.dxf a DXF, for CAD programs
.vsdx a Visio drawing
.odg a LibreOffice Draw drawing

You can also name them with --infile and --outfile, or ask for a format with --format and let the file be named after the drawing:

nodus-cmd convert --infile flow.puml --outfile flow.svg
nodus-cmd convert plan.svg --format pdf --format png --outdir exports

The second makes exports/plan.pdf and exports/plan.png. The formats are nodus, plainsvg, png, pdf, dxf, vsdx and odg; a file made with --format nodus or --format plainsvg ends .nodus.svg or .plain.svg, so it never replaces the drawing it came from. Straight after a file whose name ends just .svg, --format plainsvg makes that file a plain SVG:

nodus-cmd convert flow.puml --outfile flow.svg --format plainsvg

Options

Option Does
--crop-to-objects trims the page to the objects on it, as Trim page does
--crop-to-grid trims the page to whole grid squares round its objects
--crop-to-page keeps the page as it is (the usual)
--background white, transparent or #rrggbb the PNG's background (white unless given)
--dpi N the PNG's resolution in dots per inch (300 unless given)
--scale N the PNG N times the size it is on screen at 100 %
--page N or all which page (see below)
--auto-layout lays out the objects joined by connectors first, as Tools › Auto-layout… does
--routing as-is, curved or right-angled with it, how the connectors are drawn
--direction down, up, right or left with it, which way the diagram flows (down unless given)
--keep-layout with it, moves only what the connectors need
--move-anchors with it, lets connectors move to other anchors on each object
--keep-frames with it, keeps what is in frames (packages, subgraphs) as it is
--no-auto-layout no layout, for the files from here on
--quiet says nothing unless something goes wrong
--json gives a summary for scripts, as JSON
--help lists all this

An option applies to the file just before it and to every file after it. Options before the first file apply to every file. So this trims the Nodus drawing to the grid round its objects, and the PNG, on white, tightly to its objects:

nodus-cmd convert drawing.svg --format nodus --crop-to-grid --format png --background white --crop-to-objects

Laying out: to import a diagram, lay it out with right-angled connectors from left to right, and save it as a drawing and a PDF in one go:

nodus-cmd convert flow.puml --auto-layout --routing right-angled --direction right --format nodus --format pdf

Pages: a Nodus drawing, a Visio drawing and an ODG keep every page, and a PDF has every page; give --page 2 for just the second. A PNG, plain SVG or DXF is of the first page, or the page given; with --page all it makes one file a page, numbered (drawing-1.png, drawing-2.png…).

Exit codes

Code Means
0 every file was made
1 something on the command line was wrong (it says what, then lists the options)
2 the drawing could not be read (it says why)
3 a file could not be made (it says which and why; the others are still made)

For example, in a Windows batch file:

nodus-cmd convert plan.svg plan.pdf
if errorlevel 1 echo The conversion failed.

The command line works beside a Nodus Draw you have open, without disturbing it, and keeps nothing: it is not added to Open Recent. The portable Windows program has no nodus-cmd; with it, start /wait Nodus-Draw-…-portable.exe convert … converts and sets the exit code, but shows no messages.

Comparing two versions

nodus-cmd compare OLD NEW OUTPUT [--page N] [--dpi N] [--quiet] [--json]

compares two versions of a drawing (any files Nodus Draw opens) and writes what differs, as the comparison in Nodus Draw shows it: what is only in OLD in red, only in NEW in blue, and the rest faintly. The output's name says what it is:

  • .svg: a Nodus SVG of every page, with a layer for what is the same in both, one for what is only in OLD and one for what is only in NEW, and a key above each page. It is a drawing like any other: zoom in, or hide a layer.
  • .png: a picture of one page (the drawings' only page, or the one --page gives), with the key under it.
  • .pdf: a picture of each page (or of the one --page gives).

--dpi sets the pictures' resolution (150 unless given). --json writes a summary: how many differences each page has. The exit codes are as for convert (2 if either drawing cannot be read). For example, to see what changed in a drawing kept in git:

git show HEAD:plan.svg > old-plan.svg
nodus-cmd compare old-plan.svg plan.svg plan-changes.pdf

Next: Troubleshooting


This website is free and ad-free, but costs me money to run. If you'd like to support this site, please consider making a small donation or sending me a message to let me know what you liked or found useful.