MiddleLinePolylines_2

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 APIvlax-make-safearray Builds a safe array of doubles containing the vertex coordinates for the new polylinevlax-make-variant Wraps the safe array into a variant value required by the COM methodvla-AddLightWeightPolyline Called on ModelSpace to actually create the two vertex LWPOLYLINE objectvl-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 ellipsesFirst 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 sidesClosed curve safeguard Skips processing when a selected curve has identical start and end points, avoiding problematic closed inputMidpoint centerline Calculates midpoints between the two start points and between the two end points then draws the centerline through these midpointsPlanar output Uses only X and Y from the picked curves and ignores Z so the resulting LWPOLYLINE is a clean two dimensional objectSilent 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 curvesNon destructive The original entities remain unchanged; only an additional centerline object is createdWorkflow benefit Provides an extremely fast way to generate a central axis for profiles, corridors, or similar parallel edge situations

Images, animations etc.

Pixel

Additional info:

Share this page:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x