* 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>
* Viewports keep their own UCS and their other settings through save and copy (part of #1316)
A layout viewport's own UCS and every setting CADCraft doesn't model
were dropped on read, so saving a sheet set lost them for good.
- Viewport::ucs (origin, X/Y axes, elevation, orthographic type, named
and base UCS by name) and ucs_per_viewport (UCSVP), read from and
written as VIEWPORT groups 110-112, 146, 79, 345/346 and 71.
- Viewport::extra: the viewport's other groups as read (snap, grid,
lens and clipping, render mode, plot style sheet, shade plot, visual
style, background, lighting). They belong to the entity, so COPY and
MIRROR carry them; dxf_raw::finish writes them before the xdata and
points their references at what they named (ForeignExtra::tail).
- Not carried raw: the view twist, direction and target (51, 16, 17),
which say where the view centre is measured from; writing them back
while the centre is in drawing coordinates would move the view.
- DWG: the bridge drops 345/346, the plot style sheet, shade plot and
lighting groups, so CADCraft xdata keeps a copy (VPUCS, VPEXTRA) that
the reader falls back on. The visual style, background and shade plot
references are still lost through DWG (file-format-parity.md).
- A UCS with unreadable or zero-length axes is no UCS; a named UCS
that's no longer in the table isn't pointed at.
Tests: another program's viewport read; DXF save and reread; two DWG
round trips; a copied viewport; a deleted named UCS; a viewport without
a UCS written as before; hostile groups (5000 extras, NaN axes, bad
handles); COPY and MIRROR through the engine.
* Viewports: VPEXTRA keeps only a viewport's own groups; a base UCS handle alone is kept
- CADCraft's VPEXTRA xdata copy of a viewport's unmodelled groups is
merged only for groups that can stand inside the AcDbViewport subclass:
a record start (0), handles (5, 105), a subclass (100), a group brace
(102) or xdata (1000 on) from a crafted file are dropped, so a save
can't write records or handles the user didn't draw.
- A VIEWPORT whose only UCS group is its base UCS handle (346) now reads a
UCS, so the base UCS is resolved and written back.
* Viewports: drop structural groups from a record's own extras; index UCS names for the xdata fallback
- A VIEWPORT's own AcDbViewport groups are kept raw only when they can
stand in the subclass, as CADCraft's VPEXTRA copy already was: a second
handle (5, 105) or a group brace (102) written back would give the
record two handles. The record's own pointer groups stay, to be
remapped with it.
- The named and base UCS that CADCraft's xdata names are looked up in a
case-insensitive index built once with the UCS table, not by scanning
every UCS for each viewport.
* Parity checklist: regenerated after merging main
* Parity checklist: regenerated after merging main
* Parity checklist: regenerated after merging main
* xtask: take main's stats.rs (the merge kept a test import Linux clippy rejects)
* Viewport tests built on main set the UCS fields
* WIP row 74: Codex's test edits kept; production normalisation (identity UCS -> None, default-valued extras dropped in dxf_read viewport_ucs/viewport_extra) still to do
* Viewports: a default viewport reads back with no UCS or extra groups (#1484)
A DWG save writes an identity UCS and the default snap, grid, lens, clip,
render and shade groups for every viewport, so a viewport nobody gave a UCS
came back with one and a dozen extras. The DXF reader now reads an unnamed
identity UCS (UCSVP 0) as none, and keeps a group in extra only when it
differs from the defaults, listed in one table. Tests: a_default_viewport_reads_back_without_ucs_or_extras,
a_viewport_with_non_default_snap_keeps_it; layouts_and_paperspace passes.
* Viewports: clippy range patterns; raster_image test builds with the viewport's UCS fields
* Tests: move the viewport UCS suites into the it entry points (#1316)
viewport_ucs_roundtrip.rs and viewport_ucs_copy.rs were separate test
binaries; AGENTS section 30 wants the existing entry points. All 12 DXF/DWG
persistence tests and the COPY/MIRROR tests are kept.
* Tests: move the viewport UCS suites into the it entry points (#1316)
viewport_ucs_roundtrip.rs and viewport_ucs_copy.rs were separate test
binaries; AGENTS section 30 wants the existing entry points. All 12 DXF/DWG
persistence tests and the COPY/MIRROR tests are kept.
---------
Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: SBaksa <18648812+SBaksa@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
* Expose xdata through entities, properties.set and AutoLISP's -3 group
An entity's extended data was read, kept and written back (#528) but
invisible to the API: `entities` left it out, `properties.set` had no
field for it, `entget` never returned the -3 group and `entmod` dropped
it. Now `entities {xdata: true | "APP"}` and `properties` list it per
application with values typed by group code, `properties.set {xdata}`
replaces or removes one application's data after checking codes,
values, braces and sizes, and AutoLISP's entget/entmod/entmake carry
the -3 group, with `regapp` and the APPID table. The applications
CADCraft writes from its own model are reserved (one list, now in
cadcraft_doc, shared with the DXF reader).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Check xdata before any change in properties.set; cap entmake's xdata across applications
Review follow-ups on #2469:
- properties.set validated xdata after ensure_layer, so a request naming a new
layer and carrying bad or oversized xdata left the layer behind on failure.
The xdata checks now run first.
- entmake capped each application's groups but not their sum; an entity could
exceed MAX_XDATA_GROUPS across applications. The total is checked as entmod
already does, with a test.
- docs: the control-protocol xdata section is an h2 like its neighbours; the
file-format-parity revision row no longer has a pipe inside a code span.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* properties.set checks every handle first; a dotted -3 group is a bad list
Review follow-ups on #2469:
- properties.set edited the objects before a handle that names nothing and
then failed, keeping those edits (and a new layer). Every handle is checked
before anything changes; a missing one is refused with its hex.
- xdata_from_list read `(-3 . 7)` as "no applications" and let entmake/entmod
succeed with nothing set. A -3 whose cdr is not a list is refused (listp),
so both return nil as for any bad list.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* An xdata application's groups must be a proper list
Review follow-up on #2469: `("ACME" . 7)` in a -3 group read as "no groups",
which `entmod` takes as "remove ACME's data", and a dotted tail after real
groups was dropped. The application's tail is checked as a list (listp) like
the -3 group itself, so entmake/entmod answer nil and change nothing; test
covers both shapes.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Runs of one xdata application in any case are one application in the API
Review follow-up on #2469: a file can carry `ACME` and `acme` runs on one
entity. `entities` showed them as two JSON keys and `entget` as two lists, and
writing either back through properties.set or entmod replaced the application
twice, keeping only the last run's groups. Both projections now merge runs
case-insensitively (first spelling, all the groups), as set_xdata_app already
treats them; tests round-trip such an entity through both APIs.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Refuse raw ACAD xdata on a dimension, whose ACAD run is written from its overrides
Review follow-up on #2469 (austin62jake): properties.set accepted
`xdata: {"ACAD": …}` on a dimension and `entities` showed it, but the DXF
writer emits the dimension's ACAD run (DSTYLE) from its overrides and the
reader models it back, so the raw groups vanished on save. ACAD can't join
RESERVED_XDATA_APPS (files carry ACAD data on other entities that CADCraft
keeps raw), so the rule is per entity: `is_model_xdata_app(name, kind)` is
the reserved list on any entity plus ACAD on a dimension. properties.set
refuses it before anything changes, entmake/entmod answer nil. Tests cover
both paths, including that ACAD on a line survives a DXF round trip and the
dimension's own override does too. control-protocol.md says so.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* fix(lisp): return and accept REAL for xdata group 1071
---------
Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: FredApps <fredapps@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
* Options: preview and selection effects in Visual Effect Settings
Selection Preview Effect (Dash / Thicken / Both, PREVIEWEFFECT) as AutoCAD
offers it, and Selected Objects Effect (Dashed / Selection color,
SELECTIONEFFECT), so neither has to be typed. They stay off the Selection tab
itself.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Options test: each Visual Effect Settings choice sets its variable
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tests: the visual effect test sets up the app's headless runtime, as main's UI tests now do
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Translations to craft-i18n (AGENTS.md rule 16)
The Greek and Ukrainian rows this PR added to the app catalogs are removed; the
English keys stay, and show until craft-i18n has them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Cody Vogt <18035288+codyvogt@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A solid hatch, wide polyline, wipeout mask or filled glyph reached the PDF
writer as a triangle list, and each triangle became its own closed subpath.
The writer now cancels edges that two triangles share in opposite
directions and chains what is left into closed loops, written as one
nonzero fill. The winding number at every point depends only on the net
directed edges, so the filled area is the same for overlapping, mixed-
orientation, zero-area and T-junction triangles; vertices are matched by
the exact bits of the f32 coordinates written. O(n log n) time, O(n) memory,
no recursion.
For a 400-vertex solid hatch with a square island the page content stream
goes from 30,086 to 9,922 bytes (457 to 3 subpaths) and the compressed file
from 5,874 to 4,223 bytes.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A value of nothing but underline and overline toggles (%%u%%u) has no drawn
character, and the box floored the count at one: Aligned over a span of 20
that was a box of 20 by 120 for text that draws nothing. The box is empty
when no character is drawn, for an empty value too.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main now carries #3594 and #3622 (landed through #3692), which rewrote
clip_prim around Limits and the pieces/fill closures. The only conflict is
that block in crates/render/src/viewports.rs: main's clip_prim is kept and
its Clip::Poly fill arm gets this branch's one line, so both truncation
signals stay:
- #3594's whole() in the fill closure marks the list when the clip stops
at the room left or at its own 6,000,000-point stop;
- may_leave_out marks it when the clip region's own triangles stopped at
the fill cap (#3636).
truncated is only ever OR-ed, so neither signal clears or doubles the
other.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main (PR 3679) mirrors the box of Backwards and Upside-down text about the
point the text is placed by. This branch builds the box from a bottom and a
top instead of an offset and a height, so the mirror is applied to those
corner points.
Tests: the two helpers (ours with a vertical justification, main's with the
mirror flags) are one that takes both, and the test of the vertical
justifications also runs with each mirror.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Land #3628, #3583, #3625, #3617, #3248, #3221, #3287, #3259, #3232, #3291, #3679: Drawing Units dialog, SCALE and MOVE base points, TRIM/EXTEND Shift, mirrored hatch patterns, layout framing, deep zoom, RECTANG X/Y, Save As version, Turkish, TEXT backwards
The box took the length of the stored value, control codes included: the
%%u and %%o toggles draw nothing, %%d, %%c, %%p, %%% and %%nnn draw one
character, \U+XXXX draws one, and invisible formatting characters take no
room. So the width was over-estimated again for such text: Aligned
"%%uAB%%u" at height 1 over a span of 20 is drawn 12.5 high in a box of
6.25. The callers now pass the number of drawn characters.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The point arm repeated require_length's check and message inline; it now
calls the helper, as the Reference length already does, so the two paths
keep one threshold and one error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bottom justification lifts a line by a third of the height it is drawn at.
The box used a third of its own height, which is the most the line can be
drawn at, so the box began above the bottom of the text: "I" over a span of
20 is drawn from 20 to 80 and its box began at 40. The box now runs from
where the shortest possible line would start (from the widest width the
stroke font gives the line) to where the tallest would end.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>