ATTRIB not created on INSERT despite unique ATTDEF TAGs per block - BricsCAD V26 LISP

SL452
edited 9:05AM in LISP

Hello everyone,

I am developing a LISP routine in BricsCAD V26 that creates modular prefabricated wall panels. Each panel module is created as a separate named block, each with its own unique ATTDEF tag. Despite extensive debugging, the ATTRIBs are not reliably created after INSERT. The debug check (entnext on the inserted block) often returns nil or a non-ATTRIB entity.

BLOCK CREATION STRATEGY

  • Each module gets a fully unique block name: PM_MOD_1_L1290_H3000, PM_MOD_2_L1290_H3000...
  • Inside CreaModuloBase, geometry is created in model space, then an ATTDEF is added via entmake
  • All entities are collected in a selection set (ssadd) and the block is created via command "_BLOCK"
  • The block is then inserted with command "_.INSERT"

ATTDEF CREATION (via entmake, inside block definition)

(setq tag-univoco (strcat "COD_" (itoa numero)))
; e.g. "COD_1", "COD_2", "COD_3"
(setq valore-default (strcat "M" ...))
; e.g. "M001", "M002", "M003"
(entmake (list (cons 0 "ATTDEF") (cons 8 "PM_Numerazione")
(cons 10 testo-pt) (cons 11 testo-pt) (cons 40 100.0)
(cons 1 valore-default) (cons 3 "Codice modulo")
(cons 2 tag-univoco)
(cons 7 "Standard") (cons 70 0)
(cons 72 1) (cons 74 2) (cons 50 0.0) ))

BLOCK CREATION

(setq ss-modulo (ssadd))
; ... (entities added from ent-start to ent-end via entnext loop)
(command "_BLOCK" nome-template '(0.0 0.0 0.0) ss-modulo "")
(while (> (getvar "CMDACTIVE") 0) (command ""))

BLOCK INSERT

(command "_.INSERT" nome-blocco pt-ins "1" "1" (* angolo (/ 180.0 pi)))
(while (> (getvar "CMDACTIVE") 0) (command ""))
; Debug check:
(setq ent-inserted (entlast))
(setq ent-check (entnext ent-inserted))
(if (and ent-check (= (cdr (assoc 0 (entget ent-check))) "ATTRIB"))
(princ " /[ATT:...]/")
(princ " X[NO-ATT!]") ; <-- This is what we get!
)

WHAT WE HAVE TRIED

  1. Unique TAG per block (COD_1, COD_2...) to prevent BricsCAD moving ATTRIBs between blocks
  2. Using -INSERT (with dash) instead of INSERT
  3. Setting ATTDIA=0 before INSERT
  4. Setting ATTREQ=1 before INSERT
  5. Verified via debug that ATTDEF is correctly included in the selection set before BLOCK command

QUESTIONS

  1. Is entmake the right way to create an ATTDEF that survives the BLOCK command in BricsCAD V26? Or should ATTDEF be created differently (e.g. via -ATTDEF command)?
  2. When using command "_.INSERT" with ATTDIA=0 and ATTREQ=1, does BricsCAD V26 expect explicit string responses for each ATTRIB value before CMDACTIVE returns to 0?
  3. Is there a known issue in V26 with ATTRIBs not being created when blocks are defined and inserted fully programmatically via LISP?
  4. Would it be more reliable to create the ATTRIB manually via entmake AFTER the INSERT, attaching it to the block entity?

BricsCAD version: V26 (also tested on V25 with same result)

Thank you in advance for any help!