MARINA Posted 6 hours ago Posted 6 hours ago Hi, I need an AutoLISP routine for AutoCAD that performs an OVERKILL-equivalent cleanup directly inside block definitions, without manually opening each block using BEDIT or REFEDIT. The routine should iterate through the drawing’s BlockTable records / block definitions and process the geometry contained inside each eligible block definition. Technical requirements: Process normal user-created block definitions directly. Do not explode block references. Do not require manually opening or closing each block. Skip Xrefs, layout blocks, anonymous/system blocks, and any block definitions that should not be modified. Process nested block definitions as well, while avoiding infinite loops or repeated unnecessary processing. Remove duplicate and overlapping entities in a way equivalent, or as close as technically possible, to AutoCAD's OVERKILL command. Preserve the original block structure, insertion points, attributes, dynamic block functionality, layers, colors, linetypes, and other entity properties. Avoid modifying block references themselves unless absolutely necessary. Prefer operating directly on the entities stored in each BlockTableRecord rather than entering Block Editor. Ideally, the routine should also: Purge or ignore invalid/erased objects safely. Handle common geometry types such as Lines, Polylines, Arcs, Circles, and similar entities. Use an appropriate geometric tolerance for duplicate detection. Provide a final report showing: Number of block definitions processed. Number of blocks skipped. Number of duplicate/overlapping entities removed, if detectable. Any blocks that failed to process. My main goal is to run one command on a drawing and automatically clean duplicate geometry inside all blocks, including nested blocks, without manually opening each block one by one. Please also advise whether this can be implemented reliably in pure AutoLISP / Visual LISP, or whether a C# AutoCAD .NET plugin would be a better approach, especially if the native OVERKILL command cannot operate directly on BlockTableRecord entities. Quote
BIGAL Posted 1 hour ago Posted 1 hour ago (edited) Welcome aboard, is there a reason why you do not want to use Bedit ? Would make life a lot easier, a lisp would call bedit and select all objects in the block and could run Overkill then or something like this that I found using Google. Then save the block definition and update the dwg. ; keep longest overlapping lines ; By Saxelle Aug 2025 (defun c:DOL ( / ss len i ename_length_list ename ename_length) (setq ss (ssget (list (cons 0 "*LINE"))) len (sslength ss) i 0 ename_length_list (list) ) (while (< i len) (setq ename (ssname ss i) ename_length (getpropertyvalue ename "Length") ename_length_list (append ename_length_list (list (list ename ename_length))) i (1+ i) ) ) (setq ename_length_list (vl-sort ename_length_list (function (lambda (x1 x2) (< (cadr x1) (cadr x2))))) ename_length_list (vl-remove (last ename_length_list) ename_length_list) total_len (itoa (length ename_length_list)) ) (foreach x ename_length_list (entdel (car x)) ) (prompt (strcat "\nThe total number of deleted lines is " total_len "!")) (princ) ) A good idea with a request like this would be to post a sample dwg with the block you want to check. use wblock to pull block out of an existing dwg. Edited 1 hour ago by BIGAL Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.