Short description
Sort / Purpose: Detect and fix overlaps between vertical lines and their related TEXT or MTEXT labels by converting lines into crank polylines and then horizontally spreading texts around a vertical rail with controlled spacing.
• Scope: Works on vertical LINE objects and nearby TEXT or MTEXT annotations that share similar Y levels, using a shared spacing value and rail X coordinate.
• Goal: Quickly clean up cluttered profile or detail drawings where many lines and texts sit on top of each other, giving each line and label a readable separation without manual nudging.

Command:
Primary commands: Line_Overlap, Text_Overlap
• c:Line_Overlap: Asks for a spacing value and crank point, converts selected vertical lines into offset crank polylines, and stores spacing in *distance* plus last pick in *lastPick*.
• c:Text_Overlap: Uses the spacing from *distance* and a vertical rail X (from *lastPick* or a picked point) to horizontally offset overlapping TEXT and MTEXT on each Y row.
One shot commands:
• c:Line_Overlap_Text_Overlap: Runs Line_Overlap followed by Text_Overlap in sequence using the same spacing and rail.
• c:FixLineTextOverlap: Alias to Line_Overlap_Text_Overlap for quicker use.
Description:
• Line spacing setup: Line_Overlap starts by taking the current text size, multiplies it to get a default spacing, and lets you override this value once for the session.
• Vertical line selection: Prompts you to select LINE entities that should be treated as vertical reference lines; if none are selected the routine aborts with a message.
• Crank point: Asks you to pick a crank point which defines the Y level used to bend each vertical line into a crank shaped LWPOLYLINE, and stores this point as *lastPick* for the text routine.
• Line re geometry: For each selected line it sorts endpoints by height, deletes the original LINE, and builds an LWPOLYLINE path that goes from the top, down to the band Y, then over to the new X, and finally down to the lower Y value.
• X distribution: Collects the X coordinates of the lines, sorts them, and calls ++rarify so that new X positions are at least the requested spacing apart, preventing crank segments from overlapping.
• Text grouping: Text_Overlap reads all selected TEXT and MTEXT objects, determines their insertion points in world coordinates, and builds small records containing entity, type, side, and insertion point.
• Row detection: Groups the text records into Y based rows where items are within a small vertical tolerance of one another so only texts that could clash in the same band are processed together.
• Side separation: For each row it divides items into left and right lists relative to the vertical rail X, then designates an anchor text on each side as the closest to the rail.
• Horizontal spacing: Keeps each anchor in place and shifts remaining texts on that side by integer multiples of the spacing distance away from the rail, left side negative direction, right side positive direction.
• Coordinate writing: Writes new insertion points back to the entities, using code 10 or 11 for TEXT depending on alignment and code 10 for MTEXT, and regenerates them so the new layout is visible immediately.
• Undo protection: Line_Overlap opens an UNDO group before changes and closes it at the end or on error so all crank line edits can be undone in a single step if needed.
Helper function: (if any)
Helper for X spacing:
• ++rarify: Takes a list of X coordinates and a minimum spacing value and produces a new list where each successive value is at least that spacing apart, preserving overall order.
Text overlap helpers:
• getRec: Builds a record (ename type isLeft ipWCS) for each TEXT or MTEXT, computing a consistent world coordinate insertion point based on alignment.
• setIP: Converts a new world insertion point back into the entity coordinate system and updates the proper DXF group (10 or 11) for TEXT or MTEXT, then calls ENTUPD.
• group-by-y: Sorts records by Y coordinate and clusters them into groups where Y differences are below a given tolerance, to represent per row stacks of labels.
• order-side: For a given side relative to the rail finds the closest item as anchor then orders the remaining items from near to far so spacing is applied outward.
• place-side: Applies incremental offsets of spacing along one side, leaving the anchor fixed and moving later items step by step, then writes all new positions back with setIP.
System helpers and globals:
• Global *distance*: Holds the spacing distance chosen in Line_Overlap and reused by Text_Overlap and the combined runner.
• Global *lastPick*: Stores the last crank point used in Line_Overlap so Text_Overlap can reuse its X coordinate as a default rail.
• Local *error*: The Line_Overlap routine redefines *error* to ensure that an UNDO group is ended and that error messages are printed cleanly when something goes wrong.
Functionalities:
• Automatic crank line creation: Replaces straight vertical lines with multi segment polylines that bend at a user defined crank point while keeping a minimum horizontal spacing between them.
• Shared spacing logic: Uses one spacing value for both line crank offsets and text offsets so geometry and annotation stay visually aligned in the X direction.
• Rail based text layout: Treats a vertical rail X as the central alignment and pushes labels on both sides away from that rail in controlled steps to remove overlaps.
• Per row protection: Only texts that share a similar Y coordinate are moved relative to each other, leaving labels in other height bands untouched.
• Mixed TEXT and MTEXT support: Handles both classic TEXT and MTEXT entities, preserving left or right alignment when deciding where to move and which DXF codes to update.
• Re run friendly: Because *distance* and *lastPick* are stored, you can run Text_Overlap alone later to fix new labels using the same configuration chosen in the initial Line_Overlap run.
• Combined workflow: Line_Overlap_Text_Overlap and FixLineTextOverlap provide a single command that first cleans up vertical line positions then immediately arranges text labels to match, reducing manual steps.
Result:
Result: Vertical lines are converted into well spaced crank polylines and nearby TEXT or MTEXT labels are redistributed horizontally around a rail so that overlaps are removed and the layout becomes clear and readable.
• Cleaner profile views: Line stacks and text stacks in cross sections or detail bands no longer collide, making distance and elevation information easy to read.
• Consistent spacing: All offsets respect the same numeric spacing setting so both geometry and annotations maintain a uniform visual rhythm.
• Reduced manual editing: Many previously manual move operations are automated, especially for large numbers of lines and labels that were overlapping in tight areas.
• Undo capable changes: Because line modifications are wrapped in an UNDO group, you can revert the entire line overlap adjustment in one step if the result is not desired.
Copy code:
Images, animations etc.


Log in to download.
Log in
Log in
Additional info:
Based on / Source code:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
Tags: Section, Section View
Tags: Section, Section View
