* AutoLISP: entnext reaches an INSERT's ATTRIBs and SEQEND (#1660)
- lisp: name an INSERT's ATTRIB and SEQEND records; entnext walks them, then the next main
entity, and entget lists a record with its owner in group -2 (#1660)
- lisp: entmod of an ATTRIB takes its value (group 1) only, as one undo step; another property,
a SEQEND, entdel and entmake of one return nil and change nothing (#1660)
- doc: the handles LISP named, shared with the drawing's snapshots and never given out by
new_handle; 65,536 names, 1,024 probes past taken handles (#1660)
- io: entity_sub_record, one record of an INSERT at a time, never its other records (#1660)
- engine: an optional host hook for that record, so EntityCodec is unchanged (#1660)
- cli, web, app: install the hook; CLI tests for the walk, the value edit, the name bounds and
the refusals (#1660)
- docs: autolisp.md on the records, their names, when a name ends, and the value-only edit (#1660)
- reused from #1753 (closed), with thanks: the entity_list extraction with the -2 owner, the
writer's record splitting, and the entnext_walks_an_inserts_attribs test skeleton
* Keep AutoLISP's attribute names within their drawing
- Hold an INSERT's attribute names in the session's LISP state, not in
cadcraft_doc::Drawing: comparing drawings is plain data again and takes no
lock. The session reserves the handles in the drawing before any change, so
new_handle still never gives one out, also after a drawing swap.
- End the names when the Block Editor closes: its drawing starts from the
host's handles, so a name given there must never resolve to a host record.
- End only the erased reference's names on ERASE. Erasing another object
leaves an attribute name holding, and OOPS still revives none.
- Go on to the next entity when an INSERT has no record provider installed.
- Refuse an ATTRIB edit whose outer list ends in an atom.
* Keep issued attribute names out of the drawing.
A copied drawing could reuse a name, and storing the names in the drawing marked a saved drawing changed.
* Name an INSERT's ATTRIBs and SEQEND apart from drawing handles
An ATTRIB or SEQEND has no handle of its own in the drawing, so the
name AutoLISP gives it is now a value of its own (an entity name for
`type`), numbered from one count for the whole process that never
gives a number twice. No handle of any drawing, of a copy of one, of
another session or of another thread can be such a name, so nothing
is reserved in the handle space any more: cadcraft-doc, `new_handle`
and the copy-then-install paths are as on main, and naming or reading
a record changes neither the drawing nor its saved state.
What a name stands for (reference, place, tag) stays in the engine's
LISP state, by document. Names end on Undo, Redo, ATTSYNC,
-BLOCKREPLACE, on opening and closing the Block Editor, and when a
change is taken back; erasing a reference ends only its names, and
OOPS or `entdel` bringing it back revives none. `entupd` of a record
answers its name; selection sets and `command` take no record.
Tests cover other sessions, documents and threads giving out handles
in a drawing copy, the copy paths (INSERT from a file, XATTACH, AUDIT,
REFCLOSE), and the AutoLISP behaviour of the names.
* Keep one ATTDEF index per state of a block's entities
EntityStore gets a content token: a clone has its store's, and every
edit gives the store one that no store has had. The DXF writer keys
its ATTDEF index on that token and keeps the indexes of several
blocks, up to a fixed number of tags in all. Two copies edited apart,
or a different edit after Undo, never read each other's definition
properties, in AutoLISP reads or in a saved file, and reads that
alternate between references of different blocks examine each
definition once.
* End record names when a command puts an earlier drawing back.
MOCORO Undo restored its history drawing, handle seed included, so the next Copy could reuse the removed reference's handle. That restore now advances the name epoch. An ATTDEF index that would pass the tag budget is not stored.
* Match an oversized ATTDEF definition in full and remember it is too large to index
* Count record names with try_update, not the deprecated fetch_update
Rust 1.100 deprecates fetch_update and names try_update in its place, so
clippy with -D warnings stopped the gate at RecordName::fresh. It is the
same operation: the checked increment and the None once the count runs
out are unchanged. try_update compiles on Rust 1.95, the workspace's
minimum.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Record tests check the objects they rely on
Five tests could pass without the state they are about.
The two ATTDEF index tests changed only a layer, so both states of the
block gave T the same handle, and an index kept for the wrong state
still read the right layer. One state now keeps T on the first ATTDEF
and the other passes T to the second, on another layer. With one index
shared by every store, the old tests passed and these fail.
The MOCORO and grip Copy tests did not check that a copy was made, or
that the copy after the Undo took the removed copy's handle. They now
check both, and that the name read the first copy before the Undo.
The walk at the top of the handle range compared two values that are
both nil when the line at FFFFFFFFFFFFFFFF is not in the drawing. It
now reads that line first.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Test that entdel preserves unrelated ATTRIB names
* Fix AutoLISP record lifetime and REFEDIT edits
* Run attribute name cases in engine integration suite
* Fix text fixtures after main merge
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
TEXT, ATTDEF and ATTRIB have their own Backwards and Upside down, as AutoCAD's do (DXF group
71: 2 backwards, 4 upside down). New TEXT and attribute definitions take them from their style;
changing the style afterwards leaves existing text as it is. They were the style's only, so
text read from a file with its own flags was drawn as its style said.
- Model: `Text::backwards` and `Text::upside_down` (serde default false).
- DXF: read from 71 (the object's own groups, before an embedded MTEXT) and written when set.
- Render: drawn from the text's flags; the extents box mirrors with them, so zooming to
extents frames mirrored text. Linetype text keeps its style's.
- Properties: a Misc group with Upside down and Backwards (`properties.describe`, and
`properties.set` takes `backwards` and `upsideDown`), for several texts at once with *VARIES*.
- ATTDEF builds its text as TEXT does, so it also takes the style's width factor and obliquing.
- Round trip: #2237's matrices compare both flags, with DXF and DWG cases for them. Its
mirrored-style cases mirror the text by the text's own flags, and each mirrored style
also has text whose flags differ, so a style's flags can't leak into its text's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A LISP expression at Command: runs in 400,000-step slices, and only the
window's per-frame lisp_tick carries a routine on. Session::script gave
its next input right away and returned, so outside the window a routine
longer than one slice stopped after it for good: cadcraft-cli run and the
headless MCP server reported success with the routine cut short, and the
next LISP line got "a LISP routine is already running".
Session::lisp_run_until_input carries on such a routine until it ends or
waits for input (a get... prompt or a command pause). A script calls it
before each input it gives and once it ends, so the input goes to what
the routine waits for, or comes after it. The headless MCP backend calls
it after a command line and after Enter, since it has no frames either.
The window's own command line keeps its slices and Esc; a script in the
window, which already runs synchronously, now holds it until the routine
ends or waits.
Nobody can stop such a routine by hand, so it stops after
Limits::frameless_steps steps (BLOCKING_CAP, as a programmatic lisp call)
with the same "routine stopped after N steps" error; an endless *error*
handler is stopped one slice later.
Tests: lisp::tests::a_script_runs_a_long_routine_on_before_its_next_input,
lisp::tests::a_script_stops_an_endless_routine, cadcraft-cli
lisp_script::a_long_routine_in_a_script_draws_before_the_save and
cadcraft-mcp tests::headless_lisp_routines_run_to_their_end; all fail
without the change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first commit made `cadcraft-cli convert` print the note, but the app's
own commands write images through IoHooks::write and ::plot, which return
bytes only, so the desktop and web apps and LISP stayed silent (#1069).
- cmd::file::set_noted_io(NotedIo { write, plot }): an optional hook beside
IoHooks (which is built by struct literal in ~70 places), installed by the
CLI, desktop and web apps with cadcraft_io::write_framed_noted and the new
cadcraft_io::plotter::plot_noted / pdf::plot_noted.
- EXPORT, PLOT (so EXPORTPDF, PUBLISH and PDFBOOK per sheet), QSAVE and
SAVEAS to an image and document.bytes echo the note and add it to the
result's `warnings`. An image written with a `version` option goes through
the same writer (same bytes), so it is noted too.
- report_notes adds to `warnings` instead of replacing them;
report_dwg_notes uses it (no result had `warnings` before it, so DWG
results don't change). Without the hook nothing changes.
Not covered: the plot preview and the canvas show no message.
Fixes#1069.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dashed run is laid out over at most two million pattern elements, but
nothing bounded the total, and a pattern of mostly gaps visits many elements
for each point it draws, so the 64M-point display budget never stopped it:
1,000 lines on a 256-element pattern of gaps and one dash (a 58 KB DXF) took
11.6 s to PNG and 12.7 s to a 69 MB PDF on a dev build. A run past the
per-run limit was also drawn continuous without a word (#1069).
- MAX_DASH_ELEMENTS (64M, as many as the list's points) is charged by
linetype::layout before a run is laid out, on a counter shared like the
point budget's (parallel parts, XCLIP parts, viewport contents). Once a run
does not fit, the rest of the build's dashed runs are drawn continuous.
The per-run limit is MAX_RUN_DASH_ELEMENTS, unchanged.
- A run drawn continuous because of either limit sets DisplayList::truncated
and counts in the new DisplayList::undashed, merged where lists are joined.
Runs drawn continuous by rule (short, sub-pixel, the screen's 50,000-period
level of detail) are not counted.
- cadcraft_io::write_framed_noted (and png/svg/pdf "noted" variants) return
the note; cadcraft-cli convert and run --export print it.
- Linetype texts are placed only on a run whose dashes were laid out; phase
checks the limits without laying the run out again.
On 11 real drawings the most a complete plot asked was 26.5M elements; a
16M total would have drawn 8,241 runs of that drawing solid. With 64M the
gap-pattern file takes 0.8 s / 0.4 s, the #1069 controls and three real
drawings export byte-identical, and the audit's dense dash/gap file stays as
on main (it fills the point budget at the same time).
Part of #1923 (F-05 f). Part of #1069: the app's EXPORT and PLOT don't show
the note yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acadrust 0.6.6 writes and reads a DWG linetype's element count as one
byte, so a linetype of 256 elements came back from a DWG save with none
(continuous) and one of 300 with 44. The DXF read cap of #3482 lets 256
through, so every capped DXF linetype hit the 256 -> 0 case.
The DWG bridge text now writes at most 255 elements per linetype (the
first ones, with group 40 totalling them); DXF output is unchanged.
cadcraft_io::dwg_notes gives one note counting the linetypes cut, counted
by the writer so an xref linetype the file leaves out is not counted. An
engine hook installed by the apps echoes it and returns it in `warnings`
on every DWG write: QSAVE/SAVEAS, document.bytes, EXPORT, WBLOCK,
-WBLOCK, LAYOUT SAVEAS; cadcraft-cli convert prints it.
Part of #1923 (F-05).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A LARGE_RADIAL_DIMENSION or ARC_DIMENSION CADCraft keeps as read draws the
*D block its AcDbDimension part names, as AutoCAD does; without one, the
proxy graphics in its AcDbEntity part (the decoder learns POLYLINE_WITH_NORMAL,
chunk 32). Saving counts that block as used, so it is written and AutoCAD
reads the dimension again. cadcraft-cli no longer counts unknown entities
that draw graphics as not drawn.
Leave fixed-property visual styles out of DWG 2007 saves and count them in the save report. Expose the same count to hosts and cover the affected and unaffected save paths with synthetic tests.
PDFIMPORT (File > Import PDF...) adds a chosen page to the current drawing,
with page, scale, insertion point, password and content options. OPEN and
IMPORT take a PDF too; OPEN reads its first page into a new metric drawing,
and cadcraft-cli convert writes it to DXF or DWG.
The mapping is adapted from PR #2787 (MIT OR Apache-2.0) onto craft-pdf's
interpreter. Nonzero fills whose contours don't cross keep their loops and
arcs; crossing contours are split into triangles so the filled area matches.
Content the import leaves out or approximates is named in the read notes,
and a page with no vector content is refused instead of opening empty.
Conflicts with #2882 resolved: a DXF's loss report counts both what #2882
leaves out (solids whose ACIS geometry the version has no place for, in
either direction of 2013) and what #3234 leaves out before 2007 (proxies
whose strings it can't hold, with what goes with them), each named with its
own reason, for SAVE/SAVEAS, document.bytes, EXPORT, -WBLOCK and the
interactive QSAVE question. dxf_raw::finish takes both flags.
Kept proxy records were written with the groups they were read with. The
DWG bridge brings them in the DWG's own version's layout, so a 2010
drawing saved as an R2000 DXF carried 161/162 groups that R2000 readers
reject (ODA, BricsCAD: Out of range), and a 2018 DXF carried 95 instead
of 71/97.
DXF output now rewrites each proxy's groups after its AcDbProxy subclass
marker into the target version's form: 95 or 71/97 for the drawing
format, 92/160 graphics size, 93/161 data size, 96/162 string stream
size (none before 2007). The DWG bridge is left as it was.
From 2007 a proxy keeps its strings in a separate stream (group 96, then
162). DXF before 2007 has no such group, so converting dropped the stream's
size while keeping its bytes, and readers took them as object data. Such a
proxy is now left out of an R2000 or R2004 DXF with its dictionary entry, as
proxies of unwritten classes are, and SAVEAS and document.bytes say so on the
command line and in notSaved.
loss_on_save now lists the proxies whose strings a DXF before 2007 can't hold,
so an interactive QSAVE asks before replacing the file; the warning points to
DXF 2007 and later when proxies are what would go. The proxy report test also
The pre-save hint checked for a .dxf extension, but a save picks the
format with Format::from_path, which treats a name without one as DXF.
Such a file got "DXF keeps them" instead of the version advice.
EXPORT writes a DXF at the drawing's own version too, so before 2007 it now reports
the proxies it leaves out (echo and notSaved), as a save does.
What a pre-2007 DXF loses is now counted by the writer itself
(cadcraft_io::proxies_lost, installed in the apps with set_proxies_lost): the
drawing is written as 2007 and as the target version and the two compared.
A proxy that no version writes (its class is not written, or no written block
holds it) is no longer reported with "save as 2007 or later", and the objects
that go with a dropped proxy (its extension dictionary and the XRECORDs in it)
are reported too. The DXF writer's finish returns the foreign objects it kept
for this.
The count reads the drawing the file is written from: the committed drawing
during a reference edit (the working copy is not counted again), the drawing
EXPORT writes while the Block Editor is open (for the SAT-text report too), and
the drawing -WBLOCK writes, which now reports a pre-2007 DXF's losses as well.
- lisp: namedobjdict, dictsearch, dictnext, tblobjname; handent and entget of non-graphic objects (#1659, #1661)
- lisp: tblobjname matches names as the roles spell them; records cache held by a weak drawing reference (#1659)
- lisp: CodeRabbit follow-ups on non-graphic objects (#1659, #1661)
- lisp: test an imported DIMSTYLE's group-105 handle (#1659, #1661)
- docs: a DIMSTYLE's own name is in group 105 (#1659)
- engine: install AutoLISP's object records with their own setter (#1659, #1661)
Moves the allow_in_process call below the local use items in ten tests, matching the order every other function body in these files uses. Behavior does not change.
Every craft-libs git dependency (Cargo.toml, its [patch.crates-io]
entries and apps/cadcraft-web/Cargo.toml) moves from eleven different
revisions to craft-libs main at 3af2280ee3434a2c860012df2f440652621c2c81.
Cargo.lock keeps one copy of each craft-libs crate and adds harfrust
0.13.3 and read-fonts 0.43.3, which craft-font-catalog now needs.
craft-dwg at this revision refuses to convert DWG when no worker process
is configured (storytold/craft-libs#1345). The app and the CLI configure
one at startup and are unaffected. The tests that read or write DWG in
their own process now call cadcraft_io::dwg_worker::allow_in_process(),
which cadcraft-io re-exports. dwg_worker.rs now checks that a worker
that cannot start is an error instead of a fallback to this process.
A drawing's folder that is also a font folder or on the search path was searched again without its
guards, so a rejected link was opened on the second pass. Guards now follow the folder however the
search reaches it. The guard test held its lock across a later search and would have deadlocked, and
the font walk tests ignored an error reply from open or render.
CodeRabbit's CLI found that a name corrected to another case (Alias for alias) was looked inside
before the roots judged it, and that a case match the roots refused ended the search before the
next candidate. Each corrected name is now checked before it is probed, and each match before it
is taken. The guard test no longer expects a candidate that is never opened once an earlier one
read, and the MCP test helper refuses an error reply instead of reading it as a success.
The font search opened a candidate by name, so a link under a name the .shx filter missed (or a
Windows short name for one) was followed out of the roots. A drawing folder now carries a guard that
the search asks about every file before opening it; the roots supply it, and a link is judged by
where it leads. One font leading out no longer disables the others beside it. Documents that a
refusal inside command_line comes back in the reply's error field without isError, and adds doc
comments to the remaining functions the change touches.
A UNC, device or non-disk verbatim path was canonicalized before the roots
refused it, so on Windows the machine contacted a host the agent chose.
Those prefixes are refused first, unless a root is already on the same
server and share. A link that leads to one is refused from the link's text,
including when the link is only an ancestor of the name. The Windows tests
drop the borrows clippy rejects, and cover a junction, an alternate stream
and a Kelvin-sign name. The command walk also notices a new file when the
folder's modification time has not moved.
Under the roots the folder was skipped outright, so a drawing lost its own SHX fonts. It is now
skipped only if a font there leads out. The fixture deleted the running server's working directory
on reset, so a relative path met a missing folder and not the roots. Test folders now clean up when
a test fails. Three NO_FILES entries I added on the last merge were duplicates: those commands
already had a row.
The fixtures took a predictable name in the shared temp folder and removed whatever was there. They
now create the folder exclusively. The -WBLOCK test also shows the prompt appearing without roots, so
its absence under them is the check and not a change in the flow.
A case-sensitive Windows folder can hold Root beside root, so names are now compared exactly. The
superscript COM and LPT ports and the NUL: form are device names too. A write must stand under the
write root as well as lead there: a link outside pointing in had its .bak written beside it, and a
plotter delete removed it. Paths reach the check as paths rather than as text, -WBLOCK no longer says
whether a file outside the roots is there, and SHX fonts beside a drawing are not searched under the
roots, since one can be a link leading out.