Short description
π§© MiddleLinePolylines_2 provides the CPL_2 command for generating a simple two vertex centerline between two open curves.
π The routine averages the start points of the first and last selected curve and averages their end points.
π A new two vertex LWPOLYLINE is created in ModelSpace from those two midpoint positions.
Command:
Main command: CPL_2
Description:
π±οΈ The command accepts a general AutoCAD selection set and requires at least two selected objects.
1οΈβ£ The first object in the selection set becomes the first source curve.
2οΈβ£ The last object in the selection set becomes the second source curve.
π Curve API functions read start and end points from LINE LWPOLYLINE POLYLINE ARC SPLINE ELLIPSE and similar open curve objects.
π Closed curves are rejected when the start and end coordinates are equal.
β The source start positions are averaged to create the first centerline vertex and the source end positions are averaged to create the second.
β¬οΈ Z is explicitly forced to 0 because the result is a two dimensional lightweight polyline.
π¦ The new LWPOLYLINE is created directly in ModelSpace through COM.
Helper function: (if any)β
vlax-curve-getStartPoint reads source start coordinates.
vlax-curve-getEndPoint reads source end coordinates.
vla-AddLightWeightPolyline creates the final two vertex result.
Functionalities:
β
Simple endpoint average – creates the centerline from averaged start and end positions.
β
General curve API – works with several open AutoCAD curve types.
β
First and last selection logic – uses only the first and last objects from the selection set.
β
Closed curve guard – skips processing when a selected source appears closed.
β
Two vertex result – creates a straight LWPOLYLINE with two vertices.
β
COM creation – adds the lightweight polyline directly to ModelSpace.
β
2D output – forces the generated Z coordinate to zero.
Result:
π― The result is one straight two vertex LWPOLYLINE centered between the start and end positions of the first and last selected source curves.
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="CenterPline_2">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: CPL_2</Bold>
<LineBreak/>
<Bold>Version: 1.0 Date: 20.06.2026 6:38:59PM</Bold>
<LineBreak/>
<Hyperlink>AI + https://www.cadtutor.net/forum/topic/49702-centerline-between-two-polylines/</Hyperlink>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Description</Run></Bold><LineBreak/>
<Run Foreground="White">π§© MiddleLinePolylines_2 provides the CPL_2 command for generating a simple two vertex centerline between two open curves.</Run><LineBreak/>
<Run Foreground="White">π The routine averages the start points of the first and last selected curve and averages their end points.</Run><LineBreak/>
<Run Foreground="White">π A new two vertex LWPOLYLINE is created in ModelSpace from those two midpoint positions.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Function Syntax</Run></Bold><LineBreak/>
<Run Foreground="White">Main command: </Run><Bold><Run Foreground="Orange">CPL_2</Run></Bold><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">SEO Optimized Overview</Run></Bold><LineBreak/>
<Run Foreground="White">π±οΈ The command accepts a general AutoCAD selection set and requires at least two selected objects.</Run><LineBreak/>
<Run Foreground="White">1οΈβ£ The first object in the selection set becomes the first source curve.</Run><LineBreak/>
<Run Foreground="White">2οΈβ£ The last object in the selection set becomes the second source curve.</Run><LineBreak/>
<Run Foreground="White">π Curve API functions read start and end points from LINE LWPOLYLINE POLYLINE ARC SPLINE ELLIPSE and similar open curve objects.</Run><LineBreak/>
<Run Foreground="White">π Closed curves are rejected when the start and end coordinates are equal.</Run><LineBreak/>
<Run Foreground="White">β The source start positions are averaged to create the first centerline vertex and the source end positions are averaged to create the second.</Run><LineBreak/>
<Run Foreground="White">β¬οΈ Z is explicitly forced to 0 because the result is a two dimensional lightweight polyline.</Run><LineBreak/>
<Run Foreground="White">π¦ The new LWPOLYLINE is created directly in ModelSpace through COM.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="LimeGreen">Primary Workflow</Run></Bold><LineBreak/>
<Run Foreground="White">β’ Run CPL_2.</Run><LineBreak/>
<Run Foreground="White">β’ Select at least two curve objects.</Run><LineBreak/>
<Run Foreground="White">β’ The routine uses the first selected and last selected objects.</Run><LineBreak/>
<Run Foreground="White">β’ Start and end points are read through the AutoCAD curve API.</Run><LineBreak/>
<Run Foreground="White">β’ Start midpoints and end midpoints are calculated.</Run><LineBreak/>
<Run Foreground="White">β’ A two vertex LWPOLYLINE is created in ModelSpace.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="LimeGreen">Functionalities</Run></Bold><LineBreak/>
<Run Foreground="White">β
</Run><Bold><Run Foreground="LimeGreen">Simple endpoint average</Run></Bold><Run Foreground="White"> - creates the centerline from averaged start and end positions.</Run><LineBreak/>
<Run Foreground="White">β
</Run><Bold><Run Foreground="LimeGreen">General curve API</Run></Bold><Run Foreground="White"> - works with several open AutoCAD curve types.</Run><LineBreak/>
<Run Foreground="White">β
</Run><Bold><Run Foreground="LimeGreen">First and last selection logic</Run></Bold><Run Foreground="White"> - uses only the first and last objects from the selection set.</Run><LineBreak/>
<Run Foreground="White">β
</Run><Bold><Run Foreground="LimeGreen">Closed curve guard</Run></Bold><Run Foreground="White"> - skips processing when a selected source appears closed.</Run><LineBreak/>
<Run Foreground="White">β
</Run><Bold><Run Foreground="LimeGreen">Two vertex result</Run></Bold><Run Foreground="White"> - creates a straight LWPOLYLINE with two vertices.</Run><LineBreak/>
<Run Foreground="White">β
</Run><Bold><Run Foreground="LimeGreen">COM creation</Run></Bold><Run Foreground="White"> - adds the lightweight polyline directly to ModelSpace.</Run><LineBreak/>
<Run Foreground="White">β
</Run><Bold><Run Foreground="LimeGreen">2D output</Run></Bold><Run Foreground="White"> - forces the generated Z coordinate to zero.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Important Commands and Aspects</Run></Bold><LineBreak/>
<Run Foreground="White">π§© vlax-curve-getStartPoint reads source start coordinates.</Run><LineBreak/>
<Run Foreground="White">π§© vlax-curve-getEndPoint reads source end coordinates.</Run><LineBreak/>
<Run Foreground="White">π§© vla-AddLightWeightPolyline creates the final two vertex result.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">Result</Run></Bold><LineBreak/>
<Run Foreground="White">π― The result is one straight two vertex LWPOLYLINE centered between the start and end positions of the first and last selected source curves.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DarkRed">Important Notes</Run></Bold><LineBreak/>
<Run Foreground="White">β οΈ </Run><Bold><Run Foreground="DarkRed">The command does not calculate a detailed average path along curved source geometry.</Run></Bold><LineBreak/>
<Run Foreground="White">β οΈ </Run><Bold><Run Foreground="DarkRed">Only the first and last objects from the selection set are used.</Run></Bold><LineBreak/>
<Run Foreground="White">β οΈ </Run><Bold><Run Foreground="DarkRed">Result Z values are forced to zero.</Run></Bold><LineBreak/>
<Run Foreground="White">β οΈ </Run><Bold><Run Foreground="DarkRed">The source comment identifies this as a COM only one go centerline method.</Run></Bold><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="Yellow">SEO Keywords</Run></Bold><LineBreak/>
<Run Foreground="Yellow">π·οΈ AutoCAD, π·οΈ Civil 3D, π·οΈ AutoLISP, π·οΈ CPL_2, π·οΈ MiddleLinePolylines_2, π·οΈ Centerline, π·οΈ Endpoint midpoint, π·οΈ LWPOLYLINE, π·οΈ COM, π·οΈ CAD automation</Run><LineBreak/>
</TextBlock>
<Grid>
<MediaElement
Source="Animation_000.gif"
Stretch="Uniform"
Visibility="Visible"/>
</Grid>
</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>

Leave a Reply
You must be logged in to post a comment.