Short description
📐 MleaderStraight is an AutoCAD and Civil 3D AutoLISP utility for straightening selected MultiLeader leader lines into clean horizontal or vertical orthogonal segments.
🧭 The tool includes a compact DCL chooser that can process either manually selected MLeader objects or every MultiLeader in the current Model/Paper space layout.
Command:
🚀 Main command: MleaderStraightTools
📌 Selection mode: process preselected or interactively selected MULTILEADER objects.
📊 Current-space mode: process all MULTILEADER objects on the active CTAB layout using the 410 layout filter.
Description:
📐 MleaderStraight provides an SEO-friendly AutoCAD MLeader alignment workflow for CAD users who need cleaner annotation geometry, straighter leader lines, and more consistent Civil 3D drafting presentation.
🧩 The routine reads the first leader-line vertices from each MULTILEADER, determines whether the leader is closer to a horizontal or vertical adjustment, and rewrites the leader vertices so the resulting segment is orthogonal.
🖱️ A temporary embedded DCL dialog lets the user choose between interactive selection and all MultiLeaders in the current drawing space.
🗂️ The routine is ModelSpace and PaperSpace aware: it uses the active document space object for temporary construction geometry and uses CTAB to target the correct layout when processing all leaders.
Helper function: (if any)
🧩 rh:sammlung_n groups raw vertex coordinate lists into 3D point chunks.
🧩 MleaderStraightTools:get-space-obj returns the active ModelSpace or PaperSpace VLA object.
🧩 MleaderStraightTools:get-all-mleaders-current-space builds a selection set of all MULTILEADER entities on the current CTAB layout.
🧩 MleaderStraightTools:process-ss performs the leader vertex recalculation, temporary XLINE construction, closest-point calculation, vertex update, and viewport regeneration.
🧩 MleaderStraightTools:write-dcl-to-temp writes the embedded DCL definition to a temporary dialog file.
🧩 The local *error* handler unloads the DCL and deletes the temporary DCL file on cancellation or error.
Functionalities:
✅ Straighten MultiLeader leader geometry for cleaner AutoCAD annotation.
✅ Choose between selected MLeader processing and all MLeaders in the current space.
✅ Supports PICKFIRST preselection via ssget “_I” and manual selection via ssget.
✅ Uses MULTILEADER filters to avoid processing unrelated entity types.
✅ Creates a temporary construction XLINE only for geometric calculation and deletes it immediately after use.
✅ Regenerates all viewports after processing so the updated leader geometry is visible.
Result:
📌 Selected MultiLeader objects are updated with cleaner orthogonal leader-line vertices.
📊 The command prints the number of processed MultiLeaders at the command line.
🧹 Temporary DCL files and temporary XLINE objects are removed after processing.
Images, animations etc.
XAML code:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows">
<src:RibbonToolTip x:Key="MleaderStraight">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: MleaderStraightTools</Bold>
<LineBreak/>
<Bold>Version: 1 Date: 29.09.2025</Bold>
<LineBreak/>
<LineBreak/>
<Hyperlink>AI+https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/changing-mleader-aligner-function-to-apply-to-all-mleaders-in/m-p/9062067#M83632</Hyperlink>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Description</Run></Bold><LineBreak/>
<Run Foreground="White">📐 MleaderStraight is an AutoCAD and Civil 3D AutoLISP utility for straightening selected MultiLeader leader lines into clean horizontal or vertical orthogonal segments.</Run><LineBreak/>
<Run Foreground="LimeGreen">🧭 The tool includes a compact DCL chooser that can process either manually selected MLeader objects or every MultiLeader in the current Model/Paper space layout.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Function Syntax</Run></Bold><LineBreak/>
<Run Foreground="White">🚀 Main command: MleaderStraightTools</Run><LineBreak/>
<Run Foreground="White">📌 Selection mode: process preselected or interactively selected MULTILEADER objects.</Run><LineBreak/>
<Run Foreground="White">📊 Current-space mode: process all MULTILEADER objects on the active CTAB layout using the 410 layout filter.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">SEO Optimized Overview</Run></Bold><LineBreak/>
<Run Foreground="White">📐 MleaderStraight provides an SEO-friendly AutoCAD MLeader alignment workflow for CAD users who need cleaner annotation geometry, straighter leader lines, and more consistent Civil 3D drafting presentation.</Run><LineBreak/>
<Run Foreground="White">🧩 The routine reads the first leader-line vertices from each MULTILEADER, determines whether the leader is closer to a horizontal or vertical adjustment, and rewrites the leader vertices so the resulting segment is orthogonal.</Run><LineBreak/>
<Run Foreground="White">🖱️ A temporary embedded DCL dialog lets the user choose between interactive selection and all MultiLeaders in the current drawing space.</Run><LineBreak/>
<Run Foreground="White">🗂️ The routine is ModelSpace and PaperSpace aware: it uses the active document space object for temporary construction geometry and uses CTAB to target the correct layout when processing all leaders.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="LimeGreen">Primary Workflow</Run></Bold><LineBreak/>
<Run Foreground="White">1️⃣ Load </Run><Bold><Run Foreground="Orange">MleaderStraight.lsp</Run></Bold><Run Foreground="White"> in AutoCAD or Civil 3D.</Run><LineBreak/>
<Run Foreground="White">2️⃣ Run the command listed above from the AutoCAD command line.</Run><LineBreak/>
<Run Foreground="White">3️⃣ Follow the prompts or DCL dialog options shown by the routine.</Run><LineBreak/>
<Run Foreground="White">4️⃣ Review the result in the drawing and use AutoCAD Undo if you need to revert the operation.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Core Functionalities</Run></Bold><LineBreak/>
<Run Foreground="White">✅ Straighten MultiLeader leader geometry for cleaner AutoCAD annotation.</Run><LineBreak/>
<Run Foreground="White">✅ Choose between selected MLeader processing and all MLeaders in the current space.</Run><LineBreak/>
<Run Foreground="White">✅ Supports PICKFIRST preselection via ssget "_I" and manual selection via ssget.</Run><LineBreak/>
<Run Foreground="White">✅ Uses MULTILEADER filters to avoid processing unrelated entity types.</Run><LineBreak/>
<Run Foreground="White">✅ Creates a temporary construction XLINE only for geometric calculation and deletes it immediately after use.</Run><LineBreak/>
<Run Foreground="White">✅ Regenerates all viewports after processing so the updated leader geometry is visible.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Important Helper Functions and AutoCAD API Calls</Run></Bold><LineBreak/>
<Run Foreground="White">🧩 rh:sammlung_n groups raw vertex coordinate lists into 3D point chunks.</Run><LineBreak/>
<Run Foreground="White">🧩 MleaderStraightTools:get-space-obj returns the active ModelSpace or PaperSpace VLA object.</Run><LineBreak/>
<Run Foreground="White">🧩 MleaderStraightTools:get-all-mleaders-current-space builds a selection set of all MULTILEADER entities on the current CTAB layout.</Run><LineBreak/>
<Run Foreground="White">🧩 MleaderStraightTools:process-ss performs the leader vertex recalculation, temporary XLINE construction, closest-point calculation, vertex update, and viewport regeneration.</Run><LineBreak/>
<Run Foreground="White">🧩 MleaderStraightTools:write-dcl-to-temp writes the embedded DCL definition to a temporary dialog file.</Run><LineBreak/>
<Run Foreground="White">🧩 The local *error* handler unloads the DCL and deletes the temporary DCL file on cancellation or error.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Result</Run></Bold><LineBreak/>
<Run Foreground="White">📌 Selected MultiLeader objects are updated with cleaner orthogonal leader-line vertices.</Run><LineBreak/>
<Run Foreground="White">📊 The command prints the number of processed MultiLeaders at the command line.</Run><LineBreak/>
<Run Foreground="White">🧹 Temporary DCL files and temporary XLINE objects are removed after processing.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DarkRed">Important Notes</Run></Bold><LineBreak/>
<Run Foreground="White">⚠️ The routine modifies existing MULTILEADER vertex geometry, so test on a copy of production drawings when validating a new annotation standard.</Run><LineBreak/>
<Run Foreground="White">⚠️ It processes leader line index 0 and is intended for standard MultiLeader objects; complex MLeader configurations with multiple leader branches may need separate review.</Run><LineBreak/>
<Run Foreground="White">🧠 Best selection experience is obtained with PICKFIRST = 1 and PICKADD = 2, as noted in the source comments.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="Yellow">Tags</Run></Bold><LineBreak/>
<Run Foreground="Yellow">🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Civil 3D, 🏷️ MLeader, 🏷️ MultiLeader, 🏷️ Leader Alignment, 🏷️ MLeader Straighten, 🏷️ DCL Dialog, 🏷️ CAD Annotation, 🏷️ Drafting Automation</Run><LineBreak/>
</TextBlock>
<Grid>
<Image Source="PNG" Stretch="Uniform"/>
</Grid>
<Grid>
<MediaElement
Source="GIF"
Stretch="Uniform"
Visibility="Visible"/>
</Grid>
</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>
