AutoLISP: entmake defines blocks with BLOCK … ENDBLK (fixes #1662) (#1765)

* AutoLISP: entmake defines blocks with BLOCK ... ENDBLK (fixes #1662)

A BLOCK list wasn't an entity, so entmake returned nil and the entities
after it went into model space. Now a BLOCK list begins a definition
(name, flags, base point, description), the entities made meanwhile go
into it, and ENDBLK adds the block (redefining one of the same name, or
naming an anonymous *U block) and returns its name. An open definition,
an xref, an invalid name or a block that inserts itself is refused with
nil, using BLOCK's own name and self-reference checks.

* AutoLISP entmake blocks: review fixes (anonymous names keep a star, no redefinition during REFEDIT, a failed routine drops its open definition)

An anonymous block (flag 1) named without a * got a name like FO1; it now
gets *U. ENDBLK refuses to redefine a block REFEDIT is editing, as BLOCK
does. A routine that fails drops the definition it began, so the next
routine's entities go into the drawing; one that ends normally still
leaves it open.

* AutoLISP entmake blocks: refuse an anonymous block that inserts itself

The self-reference check ran only for named blocks, so an anonymous *U
block holding an INSERT of the name it was about to get (*U1 in an empty
drawing) was stored. The check now runs after the anonymous name is
given, for both kinds.

* AutoLISP entmake blocks: create a definition's layers only when the block is added

Each pending entity created its layer at once, so a definition ENDBLK
refused (a self-reference, REFEDIT) or a failed routine dropped left an
orphan layer. end_block now creates the layers after its checks pass,
just before it adds the block.
This commit is contained in:
Books
2026-10-24 01:49:54 -04:00
committed by GitHub
parent 1428174159
commit dadd1f227f
6 changed files with 344 additions and 3 deletions
+8
View File
@@ -82,6 +82,14 @@ DXF file holds for the object, plus `-1` (its name) and `410` (its layout). Angl
are in radians, as in AutoCAD, where the file holds degrees; `entmake`, `entmod` and `ssget`
filters take radians too.
`entmake` defines blocks: a BLOCK list (2 name, 70 flags, 10 base point, 4 description) begins a
definition, the entities made after it go into the block instead of the drawing, and an ENDBLK
list adds the block (redefining one of the same name) and returns its name. Flag 1 with a `*U`
name makes an anonymous block, named when it ends. A BLOCK while a definition is open, an
xref (flag 4), an invalid name, a block that inserts itself and a block being edited in place
(REFEDIT) return nil. A definition stays open across routines until ENDBLK, but a routine that
fails drops the one it began.
## Testing against the corpus
The AutoLISP conformance corpus (#648) lives in its own repository. Point `CADCRAFT_LISP_CORPUS`