I'm on this kick of using the standard lisp functions in my codes now, and I saw a question that seems pretty simple, how to detach all xref overlays?, so I thought I would take it up with standard lisp. My idea was to delete all inserted references, which wasn't hard, then delete the block definition, which I thought wouldn't be hard, but has proven to be hard. I have tried to delete the block_record and block, but neither one seems to work.
Any/all help is appreciated. Thanks in advance.
(defun c:Test (/ Ent tempData tempEnt tempList NewData tempName)
(while (setq Ent (tblnext "block" (not Ent)))
(if (equal (logand (cdr (assoc 70 Ent)) 8) 8)
(progn
(setq tempData
(entget
(cdr
(assoc
330
(entget (setq tempEnt (tblobjname "block" (setq tempName (cdr (assoc 2 Ent))))))
)
)
)
)
(if (setq tempList (member '(102 . "{BLKREFS") tempData))
(progn
(foreach i tempList
(if (equal (car i) 331)
(entdel (cdr i))
)
)
(setq NewData nil)
(foreach i tempData
(if (not (member i tempList))
(setq NewData (cons i NewData))
)
)
(if
(and
(entmod (reverse NewData))
(or
(entdel (cdr (assoc -1 NewData)))
(entdel (tblobjname "block" tempName))
)
)
(prompt (strcat "\n Overlay xref \"" tempName "\" has been deleted/detached."))
(prompt (strcat "\n Overlay xref \"" tempName "\" has NOT been deleted/detached."))
)
)
)
)
)
)
(princ)
)