I'm trying to create a function which will remove all attributes from any block. The attributes need to be removed from all instances of the block.
I wrote my function as below.
It deletes the attributes, but when the Attsync command is called, AutoCAD tells me the following:
"Block table contains no attributed block named SomeBlock2", and the attributes are still displayed.
If, after this function has run, I manually type "ATTSYNC", and select one of the blocks, they will properly clean up the blocks.
Is there any way of properly attsyncing the block after the attributes have been deleted using this method?
(defun DeleteAtts (BName / Binfo En El EnTyp AttSync)
(setq BInfo (tblsearch "BLOCK" BName)
En (cdr (assoc -2 BInfo))
)
(while En
(setq El (entget En)
EnTyp (cdr (Assoc 0 El))
)
(if (= EnTyp "ATTDEF")
(progn
(entdel En)
(setq AttSync T)
);end progn
);end if
(setq En (entnext En))
);end while
(if AttSync
(command "ATTSYNC" "N" Bname)
);end if
(regen)
);end defun


Reply With Quote