Short description
Purpose: Create a simple two vertex centerline between two selected open curves using only their endpoints Supported objects: LINE, LWPOLYLINE, POLYLINE, ARC, SPLINE, ELLIPSE when they are open curves Usage style: Quick central axis between two roughly parallel edges selected as first and last items in a selection set
Command:
Command name: CPL_2 How to run: Type CPL_2 then press Enter Selection: Use any selection method to choose at least two open curves; the routine uses the first and the last selected entities Silent rules: If fewer than two objects are selected or if the chosen curves are closed, the routine simply ends without creating anything
Description:
The routine takes the first and last entities from the user selection and reads their geometric start and end points through the curve API, which works for lines, polylines, arcs, splines, and ellipses. It rejects closed curves by checking that each start point is different from its corresponding end point, which prevents creating a centerline from closed loops. From these endpoints, it computes the midpoint between the two starts and the midpoint between the two ends in the XY plane, then creates a two vertex LWPOLYLINE that connects those midpoints, effectively representing a simple centerline between the two boundary curves.
Helper function: (if any)
• vlax-curve-getStartPoint and getEndPoint Used to obtain pure geometry for any supported curve object through the curve API • vlax-make-safearray Builds a safe array of doubles containing the vertex coordinates for the new polyline • vlax-make-variant Wraps the safe array into a variant value required by the COM method • vla-AddLightWeightPolyline Called on ModelSpace to actually create the two vertex LWPOLYLINE object • vl-load-com Ensures the Visual LISP COM interface is loaded before any COM calls are made
Functionalities:
• Automatic curve type handling Uses the generic curve API so the same logic works across lines, polylines, arcs, splines, and ellipses • First and last driven logic Only the first and the last objects in the selection are used, which allows flexible window or crossing selection while still defining two sides • Closed curve safeguard Skips processing when a selected curve has identical start and end points, avoiding problematic closed input • Midpoint centerline Calculates midpoints between the two start points and between the two end points then draws the centerline through these midpoints • Planar output Uses only X and Y from the picked curves and ignores Z so the resulting LWPOLYLINE is a clean two dimensional object • Silent behaviour No command line prompts are issued; if the conditions are not met, nothing is created and the routine exits quietly
Result:
• Geometric result A new two vertex LWPOLYLINE is added in ModelSpace that represents the centerline between the two selected boundary curves • Non destructive The original entities remain unchanged; only an additional centerline object is created • Workflow benefit Provides an extremely fast way to generate a central axis for profiles, corridors, or similar parallel edge situations
Learn more: Open Initial Website Source Code
Images, animations etc.
Log in to download.
Log in
Log in
Additional info:
Learn more:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
