Automatic Block Break
|Function Syntax||ABB / ABBE / ABBS|
|View HTML Version||AutoBlockBreakV1-7.html|
I've seen quite a few programs of this nature, enabling the user to automatically break an object onto which a block is inserted, and so I decided to write my own.
The program will allow a user to insert (or copy) a block at a specified point with all objects surrounding the block trimmed to the rectangular block outline as demonstrated in the animation below. In addition, with the Automatic Block Rotation option set to On, if a curve object is detected at the block insertion point, the block will be automatically rotated to align with the curve.
The method utilised by the program to trim the objects surrounding the block is to obtain the dimensions of the bounding box of the selected block at zero rotation, and, following transformation of such bounding box to account for block rotation, scale and orientation, the program tests for intersections between an LWPolyline (constructed from the bounding box coordinates), and a selection set of the surrounding objects.
This method, although accurate in most cases, makes the assumption that the points of intersection between the block and surrounding objects are the extremeties of the block.
The program offers three commands:
ABB: Auto Block Break
Upon calling the program with ABB, the program first prompts the user to select a block to insert. At this prompt the user may select a block from the drawing, or type Browse to browse for a drawing file to insert. The user may also alter the program rotation setting by typing Rotation when prompted.
Following a valid response, the program prompts the user to specify an insertion point for the block.
If a curve object (Arc, Elliptical Arc, Ellipse, Circle, Line, XLine, Spline, LWPolyline or Polyline) is detected at the block insertion point and the program rotation setting is enabled, the inserted block will be automatically rotated to align with the curve at an angle providing maximum readability of any attributes which may be present.
Finally, all surrounding compatible objects found to intersect with the inserted block are then trimmed to the rectangular block outline.
ABBE: Auto Block Break Existing
Upon calling the program with ABBE, the user is prompted to select an existing block in the drawing. At this prompt, the user may also alter the program rotation setting by typing Rotation at the prompt.
Following a valid selection, If a curve object is detected at the insertion point of the selected block and the program rotation setting is enabled, the block will be automatically rotated to align with the curve, again at an angle retaining maximum readability.
All surrounding compatible objects found to intersect with the selected block are then trimmed to the rectangular block outline.
ABBS: Auto Block Break Selection
This third command enables the user to select multiple existing blocks and automatically trim all surrounding geometry to the rectangular outline of each block.
Optionally, the program will automatically rotate each block in the selection to align with curve objects detected to pass through the block insertion point.
Users that are proficient in AutoLISP may also design & create their own Automatic Block Break custom programs by calling the LM:AutoBlockBreak function which is the core engine of the programs described above.
This function requires two arguments: the entity name of the block reference to be processed, and a boolean flag determining whether or not the supplied block reference should be automatically rotated to align with any objects passing through the block insertion point.
Examples of how to correctly call this function from another program may be found by studying the code for the above commands offered by this program.
Instructions for Running
Please refer to How to Run an AutoLISP Program.