Delete From Layouts
See also Copy to Layouts.
Function Syntax | DFL / DFAL |
Current Version | 1.0 |
Download | DeleteFromLayoutsV1-0.lsp |
View HTML Version | DeleteFromLayoutsV1-0.html |
Compatible with AutoCAD for Mac? | No |
Compatible with AutoCAD LT? | Yes |
Donate |
Program Description
This program enables the user to quickly delete a selection of objects from all or selected Paperspace layouts in the active drawing.
The program defines two custom commands which may be invoked from any Paperspace layout within a drawing containing more than one Paperspace layout.
DFL: Delete From Layouts
The first command DFL (Delete From Layouts) prompts the user for a selection of objects in the current layout, and then presents the user with a dialog interface (generated by my List Box function, as illustrated below) through which one or more target layouts may be selected from which objects matching the selection will also be deleted.
The program will then automatically delete objects matching the selection from the selected layouts and the current layout.
DFAL: Delete From All Layouts
The second command DFAL (Delete From All Layouts) prompts the user for a selection of objects in the current layout, as above, but then promptly deletes objects matching the selection from all Paperspace layouts in the active drawing, including the current layout.
Selection Matching Method
When designing a program which involves matching sets of unassociated & distinct objects across multiple layouts, there are several possible methods which may be employed.
The simplest and perhaps most obvious method might be to determine the area occupied by the selection, the 'selection window', and delete objects residing within a similar selection window in other layouts. However, this indiscriminatory selection method will merely erase any object which happens to be located within a given area of a layout and thereby risks erasing objects which bear no resemblance to those found in the selection.
A far more rigourous method might be to compare the DXF data of every object in the selection with that of every object in each layout, only deleting those objects for which all DXF groups pertaining to the properties & geometry of the objects match. However, this necessitates that for an object to be a match, it must not only be an identical visual match, but must also have been constructed in an identical manner, e.g. lines & polylines which look identical but have reversed vertices would not consitute a match.
As such, this program leverages a method which lies somewhere in the middle-ground of the above two approaches. In this program, two objects are considered a match if they share the same object type and basic properties (layer, colour, linetype and lineweight), and have the same bounding box. This relatively basic method of comparison may therefore be applied to all types of object, with a relatively small chance that two visibly different objects will have the same properties and geometric extents, occupying exactly the same area of the drawing.
Dialog Preview

Instructions for Running
Please refer to How to Run an AutoLISP Program.