Skip to content

ATTOUT and ATTIN: export and import block attribute values - #14

Merged
withshalom merged 1 commit into
mainfrom
feat/attout-attin
Nov 13, 2026
Merged

withshalom merged 1 commit into
mainfrom
feat/attout-attin

Conversation

@SkryxDev

Copy link
Copy Markdown
Member

Adds ATTOUT and ATTIN, the Express Tools' Export / Import Attribute Information, asked for on Discord.

What they do

  • ATTOUT writes the attribute values of the chosen block references to a tab-delimited .txt file: a header HANDLE, BLOCKNAME, then one column per tag (the union of tags over the references, in the order first met); one row per reference, its handle written as '1A2 so a spreadsheet keeps it as text. A cell is empty when a block has no such tag; a repeated tag in one block becomes TAG(2). Values with tabs, quotes or line breaks are quoted. UTF-8 with a BOM, CRLF. The default file is the drawing's name with .txt.
  • ATTIN reads such a file back and updates the references it names by handle, all in one undo step. Rows whose handle is missing or isn't a block reference are skipped; tags not in the file (and <> cells) are left alone; an empty cell clears a value; references on locked layers (or attributes on a locked layer of their own) are left alone. It reports references and values updated, rows skipped, locked references and unknown tag columns.

Where

  • Engine commands in crates/engine/src/cmd/blocks/attio.rs (attout, attin), menu Tools ▸ Express Tools ▸ Export/Import Attribute Information....
  • JSON forms (MCP, CLI, scripts, control channel, no dialogs): attout {path?, handles?} (no path: the file's text comes back as text; no handles: the selection, else every attributed reference in the current space); attin {path | text, handles?} (handles limits which references may change).
  • Interactive forms: ATTOUT asks for the file, then Select objects (pickfirst honoured); ATTIN asks for the file. From the ribbon, menu or typed in the app, a native save/open dialog comes first (FILEDIA 0 or no dialog → the command line asks).
  • Ribbon: Extra Tools ▸ Blocks (next to Explode Attributes / Replace Block) and the Home tab's Edit Attributes drop-down. Two new icons drawn in icons.rs (block + sheet, arrow out / in). The Save dialog gains a Text, tab-delimited (TXT) filter.
  • Italian translations in it.tsv, menu entries (and the prompts) in zh.tsv.

Hostile input

ATTIN reads through capped_read (32 MB cap, regular files only), caps rows (200 000), columns (2 000) and cell size (64 KB), refuses an unclosed quote, and changes nothing if any of that fails. It decodes UTF-8 (BOM or not), UTF-16 LE/BE with a BOM (a spreadsheet's "Unicode text") and otherwise Windows-1252; CRLF, LF and CR line ends; control characters are dropped and line breaks become spaces in single-line attributes. On the web, ATTOUT downloads the file through the delivery hook; ATTIN takes text (no file system there). Behaviour observed black-box only.

Tests

  • crates/engine/tests/it/attout_attin.rs: file format and union of tags, round trip ATTOUT → edit → ATTIN → undo/redo as one step, unknown handles and other objects skipped, handles limit, missing tags / <> / short rows / case-insensitive tags, locked layers, hostile files (unclosed quote, oversized cell, too many columns, file over the cap, folder, missing file, junk, control characters, Windows-1252, UTF-16), the command-line forms and a script.
  • Unit tests for the parser, decoder and handle cells in attio.rs; a UI test that the ribbon form asks for the file and JSON calls open no dialog.
  • Checked in the running app (--sample --control): the ribbon buttons start the commands, a file edited outside was imported (2 references, 3 values, 1 unknown-handle row skipped) and U took it back in one step.
  • cargo xtask ci: fmt, clippy, i18n, assets, layers and wasm pass; every test passes except the 3 known macOS-only ones (usage::non_unicode_output_names, read_file_refuses_a_name_that_is_not_unicode, thai_marks_stack_in_an_installed_font).

🤖 Generated with Claude Code

…and back

The Express Tools' Export / Import Attribute Information. ATTOUT writes one
row per block reference (handle with a leading apostrophe, block name, one
column per tag over the union of tags) to a UTF-8 .txt; ATTIN reads it back
and updates the references it names by handle in one undo step, skipping
unknown handles, leaving missing tags, `<>` cells and locked layers alone.
File input is capped (size, rows, columns, cell length) and decoded from
UTF-8, UTF-16 or Windows-1252. JSON forms take `path`/`text` and `handles`;
the ribbon (Extra Tools > Blocks, Home's Edit Attributes drop-down) asks for
the file first. New icons, Italian and Chinese strings, tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SkryxDev
SkryxDev requested a review from withshalom November 13, 2026 19:58
@withshalom
withshalom merged commit ebeebd9 into main Nov 13, 2026
1 check passed
@SkryxDev
SkryxDev deleted the feat/attout-attin branch November 13, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants