Skip to content

Command-Line Tool ​

plancount does from a terminal or a script what the REST API does: manage projects and drawings, set up pages and scales, read and change rules, zones, line and ring measurements, annotations and legends, read the takeoff, place and move symbols, make and download marked-up PDFs and CSV files, and check your credits.

Install ​

You need Node.js 20 or newer.

bash
npm install -g @plancount/cli

Or run it once without installing:

bash
npx @plancount/cli --help

The command you type is plancount.

Sign in ​

Create an API key on the Account page with the scopes you need (read, upload and edit; see permissions). Then:

bash
plancount login        # asks for the key without showing it, checks it, saves it
plancount whoami       # workspace, scopes and key prefix
plancount logout       # forgets the saved key

login saves the key in ~/.config/plancount/config.json. The file is readable only by you. The key is never printed again.

For scripts and CI, set the environment instead of saving anything:

VariableMeaning
PLANCOUNT_API_KEYThe key. Wins over a saved key
PLANCOUNT_API_URLThe API address. Default https://api.plancount.ai

The key only travels over https://. The tool refuses to send it to an http:// address, except http://localhost and http://127.0.0.1.

Output and errors ​

Every command that shows data takes --json, which prints the API's answer exactly as it came, for scripts. Without it you get a short table or sentence.

Errors go to stderr as the API's code and message, for example:

Error PROJECT_NOT_FOUND: Project not found

Credit problems add what you need to act: INSUFFICIENT_CREDITS shows the credits required and available and a link to buy more, MAX_CREDITS_EXCEEDED the price and your cap, and KEY_DAILY_LIMIT_EXCEEDED the key's limit and when some of it frees up. A refused batch (VALIDATION_FAILED) lists each failing operation. When the server says to wait (Retry-After), the tool shows it. With --json, the error body is written to stderr unchanged.

Exit codes ​

CodeMeaning
0Done
1Could not reach the API, a download stopped early, or the answer was not understood
2Bad arguments, a file that cannot be read or written, or an unsafe API address
3Not signed in, the key was refused, or it lacks the needed scope
4Credits: not enough, over --max-credits, or over the key's daily limit
5The API refused the request (not found, invalid, conflict, and so on)
6Try again later: busy or server trouble, an error marked retryable, or "send the same command again"

Commands ​

Ids are the ones projects list and projects get show. Points are in page units: the top-left corner of the page is 0,0 and y grows downward, the same numbers text and symbols list give. See Coordinates.

Projects ​

bash
plancount projects list [--limit 20] [--cursor <cursor>]
plancount projects get <projectId>
plancount projects create "Level 1" --description "Ground floor" --profile LIGHTING
plancount projects rename <projectId> "Level 1 (rev B)"
plancount projects archive <projectId>            # and: unarchive
plancount projects duplicate <projectId> --name "Level 1 copy"
plancount projects delete <projectId> --confirm <projectId>

projects create makes an empty project. Profiles: LIGHTING, NETWORK, POWER, FIRE, SECURITY. None of these commands spend credits. delete cannot be undone, so it refuses to run unless --confirm repeats the id you gave. Without it nothing is sent.

Drawings in a project ​

bash
plancount pdfs remove <projectId> <pdfId> --confirm <pdfId>   # also deletes everything placed on that drawing
plancount pdfs reorder <projectId> <pdfId> <pdfId> ...        # every drawing of the project, once, in the new order

Upload (spends credits) ​

bash
plancount upload level1.pdf --name "Level 1" --max-credits 20     # new project
plancount upload level2.pdf --project <projectId>                 # add to a project
plancount upload plan.pdf --pages 1,3,5-7                         # only those pages, and pay only for them
plancount upload --estimate --pages 12                            # price check; uploads nothing

An upload costs 1 credit for each page. --max-credits refuses the upload, before anything is charged, if the price is higher.

--pages has two meanings. Without --estimate it selects pages: --pages 3 uploads only page 3. With --estimate, a single number is a page count to price (--pages 3 is priced as 3 pages) and a list is counted (--pages 1,3,5-7 is priced as 5 pages). The command prints how it read --pages. PDFs that are secured against changes cannot have pages selected; upload the whole file.

Each upload carries an Idempotency-Key made from the file's contents, its name and where it is going. If the connection drops, run the same command again and you are not charged twice. For the same reason, uploading the very same file to the same place again within a day returns the first result instead of adding it twice, even if you deleted the project in the meantime. To upload it again anyway, use a different --name or rename the file.

Read a drawing ​

bash
plancount rules <projectId>                                # detection rules
plancount text <projectId> <pdfId> 2                       # page text with positions
plancount download <projectId> <pdfId> -o level1.pdf       # the stored original PDF
plancount image <projectId> <pdfId> 2 --dpi 100 -o p2.png  # a page as a PNG (dpi 36 to 200)
plancount counts <projectId> [--pdf <pdfId>] [--page 2]    # symbol counts as the app shows them

A page image has scale pixels per page unit (dpi / 72), so pixel (px, py) is the page point (px / scale, py / scale). image prints the scale.

Symbols ​

bash
plancount symbols list <projectId> [--pdf <pdfId>] [--page 2] [--include-removed]
plancount symbols place <projectId> --pdf <pdfId> --page 2 --at 120.5,340 --rule <ruleId> [--label A1]
plancount symbols move <projectId> <symbolId> --to 130,340
plancount symbols remove <projectId> <symbolId> [<symbolId> ...]
plancount symbols apply <projectId> ops.json

apply takes a file holding an array of operations (place, move, remove, restore, up to 500), or an object { "ops": [...], "expectedVersion": 12 }. A batch is all or nothing. Every symbol command accepts --expected-version <n>: the change is refused if the project has changed since that state version.

Page setup ​

bash
plancount pages <projectId>                                              # each drawing: scale, pages, excluded pages, hidden labels
plancount pages exclude <projectId> --pdf <pdfId> --pages 2,4-5          # leave pages out of takeoff and exports; and: pages include
plancount scale set <projectId> --pdf <pdfId> --ratio 100 --unit metric [--label "1:100"]
plancount scale clear <projectId> --pdf <pdfId>                          # back to the default 1:100 metric
plancount labels hide <projectId> A1 B2                                  # leave labels out of totals; and: labels show

Rules, zones, lines and rings, annotations, legends ​

bash
plancount list <projectId> rules                    # also: zones, linear, annotations, legends
plancount list <projectId> zones --pdf <pdfId> --page 2
plancount apply <projectId> zones zones.json        # also: rules, linear, annotations, legends, page-setup, symbols
plancount apply <projectId> rules rules.json --expected-version 12

list shows the collection and the state version to use as --expected-version. --pdf and --page filter where the collection is per page.

apply takes a file holding the batch's ops array (or { "ops": [...], "expectedVersion": 12 }), 1 to 500 operations, all or nothing. If any operation is refused (VALIDATION_FAILED), nothing is changed and each failing operation is listed by its position (0 is the first). --expected-version <n> refuses the batch if the project has changed since the state version list showed. The operations are the ones in Project Contents. For example, zones.json:

json
[{ "op": "create", "pdfId": "<pdfId>", "page": 1, "type": "EXCLUSION", "points": [{ "x": 40, "y": 40 }, { "x": 300, "y": 40 }, { "x": 300, "y": 200 }] }]

Changing a rule's pattern runs text detection again on every drawing, and deleting a rule deletes its symbols. See Rules.

Takeoff ​

bash
plancount takeoff <projectId> [--pdf <pdfId>] [--page 2]

Shows symbol totals by label, zones with their areas, and line and ring lengths. It is free.

Exports ​

bash
plancount export <projectId> --estimate --pdf <pdfId>                    # the price; nothing is made
plancount export <projectId> --pdf <pdfId> -o level1-markup.pdf          # marked-up PDF of one drawing
plancount export <projectId> --pdf <pdfId> --pdf <pdfId2> -o all.pdf --max-credits 10   # several drawings in one PDF
plancount export <projectId> -o everything.pdf                           # every drawing in the project
plancount export <projectId> --format csv --pdf <pdfId> -o takeoff.csv   # takeoff CSV of one drawing
plancount exports list <projectId>                                       # exports you can still download (7 days)
plancount exports download <projectId> <exportId> -o again.pdf           # free

export makes the file and then downloads it. The two kinds of PDF export are priced differently, as in the app: one --pdf is like the app's Export button (credits for the pages that have counted symbols, free when none has one), while two or more --pdf, or none on a project with several drawings, is like its Export All (credits for every page that is not excluded). A CSV needs exactly one --pdf. Run export --estimate with the same arguments first to see the price. Workspaces with unlimited exports pay nothing. --max-credits refuses the export, before any charge, if it would cost more.

Run the same export command again after a dropped connection and you are not charged twice. If anything the file is made from has changed since (symbols, zones, scales, excluded pages, drawings added, removed or reordered, the project renamed), it is a new, separately charged export. If the file was made and paid for but the download fails, the command prints the export id and the exports download command that fetches it again at no cost.

Credits ​

bash
plancount credits                      # workspace, balance, available now, this key's daily limit, buy link
plancount credits transactions --limit 20

Available is the balance minus credits held for running work, which is what you can spend now.

Example ​

bash
plancount upload level1.pdf --name "Level 1" --max-credits 5
plancount takeoff <projectId>
plancount pages exclude <projectId> --pdf <pdfId> --pages 2
plancount export <projectId> --pdf <pdfId> -o level1-markup.pdf --max-credits 2

Plan Count User Guide