MleaderStraight

Short description

  • MLeader Perp Align + DCL chooser (Model or Paper space aware)
  • Aligns MLeader landing by projecting the first vertex to a perpendicular reference through the end vertex
  • Scope chooser: interactive selection or all MLeaders in current space/layout
  • Works in ModelSpace or PaperSpace based on current active space

Command:

  • MleaderStraightTools

Description:

  • Displays a small DCL dialog to choose processing scope: select MLeaders interactively or process all MLeaders in the current space.
  • Detects whether you are in ModelSpace or PaperSpace and uses the corresponding VLA space object for temporary geometry and updates.
  • For each MLeader, reads leader vertices, computes an orthogonal alignment reference through the end point, then resets the leader line vertices to straighten/perpendicularly align the leader segment.
  • Regenerates viewports and reports how many MultiLeaders were processed.

Helper function: (if any)​

  • rh:sammlung_n — groups a flat list into chunks of N (used to convert vertex arrays into 3D point lists).
  • MleaderStraightTools:get-space-obj — returns the active VLA space object: ModelSpace if ActiveSpace is model, otherwise PaperSpace.
  • MleaderStraightTools:get-all-mleaders-current-space — builds a selection set of all MULTILEADER objects in the current space/layout using group code 410 = current CTAB name.
  • MleaderStraightTools:write-dcl-to-temp — writes embedded DCL text to a temporary .dcl file and returns the file path for loading.

Functionalities:

  • DCL scope chooser — dialog offers Select MLeaders interactively (default) or All MLeaders in current space.
  • Interactive selection — attempts preselection with ssget "_I"; if none, prompts user to select MLeaders and finish with Enter; supports typical add/remove behavior depending on selection settings.
  • All-in-space selection — uses a global filter ssget "_X" restricted to current CTAB to process all MLeaders on that space/layout.
  • Per-MLeader vertex read — reads leader vertices via GetLeaderLineVertices for leader index 0, groups into 3D points, and uses the first two points as begin/end reference.
  • Choose perpendicular reference — compares ΔX vs ΔY between begin/end to decide whether to create a vertical or horizontal XLINE through the end point.
  • Project begin point — finds closest point from the begin point to that XLINE (perpendicular projection), then deletes the XLINE.
  • Rewrite leader vertices — updates leader line vertices to a two-point list (b_pt r_pt) using SetLeaderLineVertices for leader index 0.
  • Regen + report — calls Regen and prints processed count; prints “Nothing to process” if selection set is empty.
  • Robust cleanup — custom *error* handler unloads dialog, deletes temp DCL file, and reports non-cancel errors.

Result:

  • MLeaders are adjusted so the leader segment is “straightened” by projecting the begin vertex to a perpendicular reference line through the end vertex (horizontal or vertical, chosen automatically).
  • You can run the command in either ModelSpace or PaperSpace; the routine uses the current active space and can process either a chosen set or all MLeaders in the current layout/space.
  • After processing, the drawing regenerates and the command prints how many MultiLeaders were processed, or indicates nothing was found/canceled.

Images, animations etc.

Pixel

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>Description</Bold><LineBreak/>
This program allows you to automatically straighten <Span Foreground="DarkRed">MLeaders</Span> in AutoCAD so that their leader lines become perpendicular (horizontal or vertical) to the arrow base.<LineBreak/>
The user is given a small <Span Foreground="Blue">dialog box (DCL)</Span> to choose how to process the MLeaders.<LineBreak/>

<Bold>Functionalities</Bold><LineBreak/>
• Option 1: <Span Foreground="DarkRed">Select MLeaders interactively</Span><LineBreak/>
   – You can pick objects manually, use windows or crossing windows.<LineBreak/>
   – Supports <Span Foreground="Green">Ctrl</Span> to add more and <Span Foreground="Green">Ctrl+Shift</Span> to unselect.<LineBreak/>
   – Also supports <Span Foreground="Blue">preselection</Span> (objects selected before running the command).<LineBreak/>
• Option 2: <Span Foreground="DarkRed">Process all MLeaders</Span> in the <Span Foreground="Blue">current space</Span><LineBreak/>
   – Works in <Span Foreground="DarkRed">Model space</Span> or the <Span Foreground="DarkRed">active Paper space layout</Span>.<LineBreak/>
   – Automatically collects all MLeaders from the active tab.<LineBreak/>
• After processing, leader lines are adjusted to be <Span Foreground="DarkRed">straight</Span> (either vertical or horizontal), depending on their relative positions.<LineBreak/>
• Temporary construction lines (<Span Foreground="Blue">XLINE</Span>) are created and deleted during processing to calculate exact perpendicular points.<LineBreak/>
• The drawing is <Span Foreground="DarkRed">regenerated</Span> (<Span Foreground="Blue">REGEN</Span>) after modification.<LineBreak/>

<Bold>Command Name</Bold><LineBreak/>
Run the command by typing: <Span Foreground="DarkRed">MleaderStraight</Span><LineBreak/>

<Bold>Notes</Bold><LineBreak/>
• Works seamlessly in both <Span Foreground="DarkRed">Model</Span> and <Span Foreground="DarkRed">Paper space</Span>.<LineBreak/>
• Best experience when <Span Foreground="Blue">PICKFIRST=1</Span> and <Span Foreground="Blue">PICKADD=2</Span>.<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>



Additional info:

Share this page:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Tags: 🏷️ Autocad Lisps, 🏷️ Dim_leader_menu, 🏷️ Dimnesions, 🏷️ Leader
0
Would love your thoughts, please comment.x
()
x