CompuServe Messages

Nested Block Access

    20-Feb-92 14:12:09
Fm: Tony Tanzillo [LISP TM] 71241,2067
To: Cynthia Chaney 70642,2520
Cynthia – I'll assume that when you say "I have a block named TEMP and within that block is another block named TEMP1", means that the block TEMP contains an INSERTION of the block TEMP1. Be that the case, you can access the defining entities of any block, using the (tblsearch) function. This function returns a list similar to that returned by the (entget) function. The -2 group in this list, is the entity name of the first defining entity in the block (unless the block has no defining entities, in which case, the -2 group will contain the entity name of the ENDBLK entity). You can then use (entnext) and (entget) to examine the defining entities in a block, once you've obtained the entity name of the first entity from the block table entry's -2 group. If you apply this to your TEMP block, then you will find the insertion and attributes of the TEMP1 block, in the defining entities of TEMP. For example: (setq block_data (tblsearch "block" "TEMP")) (setq ent (cdr (assoc -2 block_data))) (while ent (setq edata (entget ent)) (if (and (eq (cdr (assoc 0 edata)) "INSERT") (eq (cdr (assoc 2 edata)) "TEMP1") ) (princ "\nFound an insertion of TEMP1") ) (setq ent (entnext ent)) ) -TonyT.