Skip to content

Reading settings

Theme
Text size
Line spacing
Reading width
Code text size
Dyslexia-friendly font · Motion

The command line

CompleteChecked against Musa CAD 0.8.0Verified

The musacad program can do three things from a terminal or a script, without opening a window:

  • open a drawing in the normal window: musacad part.musa
  • check a drawing and report problems: musacad --check part.musa
  • print a drawing to PDF: musacad --plot part.musa part.pdf

--check and --plot need no screen at all. They work over SSH, in a scheduled job, on a build server and inside a container.

InstallRun
Windows"C:\Program Files\Musa CAD\musacad.exe". Use musacad.exe, not musacad_app.exe, so scripts wait for it and see its exit code.
Linux AppImage./MusaCAD-0.8.0-x86_64.AppImage. On a server without FUSE, put APPIMAGE_EXTRACT_AND_RUN=1 in front.
Linux Flatpakflatpak run --filesystem=home org.musacad.MusaCAD. The --filesystem part lets it read your files.
macOS/Applications/MusaCAD.app/Contents/MacOS/musacad_app
Built from sourcebuild/release/bin/musacad_app

The examples below just say musacad.

Terminal window
musacad --check part.musa && echo "ok"

Musa CAD reads the drawing with exactly the code the program itself uses. If the file is broken, it says which line, and exits with code 2:

Terminal window
$ musacad --check broken.musa
musacad: broken.musa: LINE record malformed (line 2).
$ echo $?
2

If the drawing opens, --check then looks at every text the way a person checks a sheet before it goes out, and reports any text that:

  • overlaps another text;
  • runs outside the frame, which is the drawing’s largest rectangle (such as a border), or the area you give with --window x0,y0,x1,y1;
  • uses a character the font cannot draw, which would come out blank on paper;
  • with --lines, is crossed by a line. A dimension’s own lines and a leader’s line do not count.

When it finds a problem, it lists it and exits with code 4:

Terminal window
$ musacad --check board.musa
board.musa: Opened 214 entities.
board.musa: overlap: TEXT "R1 750 Ω" (layer NOTES, at 10.2,10) and TEXT "C3" (layer NOTES, at 14.2,10.5)
board.musa: outside the frame: TEXT "REV B" (layer TITLE, at 410.4,6)
board.musa: 38 texts checked, 2 problems

Add --json to get the same report as JSON, for a program to read. Each problem has a kind (overlap, outside-frame, crosses-line or missing-glyph), the text’s layer, position and exact box, and what it collides with.

Terminal window
musacad --plot drawing.musa out.pdf --paper A3 --landscape --scale 1:5
OptionWhat it does
--paper <name>A4 A3 A2 A1 A0 Letter Tabloid. The default is A4.
--landscape, --portraitSheet orientation. The default is landscape.
--extentsPrint the whole drawing. This is the default.
--window x0,y0,x1,y1Print only this rectangle of the drawing. The corners can be in any order.
--fitScale the drawing to fill the sheet. This is the default.
--scale <n:m>Print n mm on paper for every m drawing units, for example 1:5. This turns --fit off.
--monochromePrint everything in black.

The PDF is made by the same code as Plot in the program, so linetypes, lineweights, hatches and text come out exactly the same. It is real vector output, not an image.

Scripts can rely on these:

Exit codeMeaning
0success
1usage error (bad command line)
2the drawing could not be read or parsed
3the output could not be written
4--check: text overlaps text, leaves the frame, crosses a line (--lines) or uses a character the font has no glyph for
Terminal window
mkdir -p out
for f in sheets/*.musa; do
musacad --plot "$f" "out/$(basename "${f%.musa}").pdf" --paper A3 --landscape || exit 1
done
# A GitHub Actions step: fail the job if any drawing does not open or has text problems.
- name: Check drawings
run: |
for f in drawings/*.musa; do
./MusaCAD-0.8.0-x86_64.AppImage --check "$f" --lines || exit 1
done
env:
APPIMAGE_EXTRACT_AND_RUN: 1
Terminal window
for %%f in (sheets\*.musa) do (
"C:\Program Files\Musa CAD\musacad.exe" --plot "%%f" "out\%%~nf.pdf" --paper A3 || exit /b 1
)

This is exactly what musacad --help prints. It is read from the program when this wiki is built:

musacad --help (Musa CAD 0.8.0)
Musa CAD -- 2D CAD engine
Usage:
musacad [<drawing>] open a drawing in the GUI
musacad --check <drawing> [check options]
read a drawing, check its text, report, exit
musacad --plot <drawing> <out.pdf> [plot options]
plot to PDF headlessly (no display needed)
musacad --dump-wiki-data <out.json>
write the commands, ribbon and keyboard
shortcuts as JSON, for the documentation
musacad --help show this help
musacad --version show the version
<drawing> is a .musa file, or a .dxf file (loaded through the DXF importer).
Plot options:
--paper <name> sheet: A4 A3 A2 A1 A0 Letter Tabloid (default A4)
--landscape sheet orientation (default)
--portrait sheet orientation
--extents plot the drawing's extents (default)
--window x0,y0,x1,y1 plot an explicit world rectangle
--fit scale the area to fill the sheet (default)
--scale <n:m> plot n mm per m drawing units, e.g. 1:5
--monochrome plot everything black (the mono CTB style)
Check options:
--window x0,y0,x1,y1 the frame text must stay inside (default: the
drawing's largest rectangle)
--lines also report text that a line crosses
--json print the report as JSON
Exit codes:
0 success
1 usage error (bad command line)
2 the drawing could not be read or parsed
3 the output could not be written
4 --check: text overlaps text, leaves the frame, crosses a line (--lines)
or uses a character the font has no glyph for
Single-dash options are passed through to Qt (e.g. -platform offscreen).

Options with one dash, such as -platform offscreen, are passed to Qt, the toolkit Musa CAD is built on.