Short description
Purpose: Convert REGION objects into closed LWPOLYLINEs while preserving curve continuity and arc bulges Typical use: Cleanup of Boolean-created geometry or boundary extractions that output REGION entities Input object: REGION only — all selected REGIONs are processed Output format: Clean, closed LWPOLYLINE with correct bulges and segment ordering
Command:
Command name: Region2Polyline How to run: Type Region2Polyline or call c:Region2Polyline Selection mode: Automatically selects all REGION objects in the drawing (ssget “_x”) Operation: Converts each REGION into a closed LWPOLYLINE using Gilles Chanteau’s algorithm
Description:
The routine collects all REGION entities and processes them one by one by exploding each REGION into its primitive components — lines and arcs. It reorders these exploded segments so that they form a continuous closed loop, maintaining correct sequencing and connectivity between endpoints. For ARCs, it computes the corresponding bulge value using the arc’s total angle, allowing reconstruction of the curvature when converting back to LWPOLYLINE format. After ordering segments, it builds a new closed LWPOLYLINE from the reconstructed point list, applies bulges where needed, restores the elevation and normal vector, and then deletes the original REGION geometry.
Helper function: (if any)
• *error* Handles unexpected termination, prints an error message unless canceled, and ends the undo mark • arcbulge Calculates bulge from an ARC’s total angle → sin(a/4) ÷ cos(a/4) • Explode logic Uses vlax-invoke reg ‘Explode to decompose REGION into lines and arcs • Segment ordering scan Reassembles segments by repeatedly finding the next segment whose start or end matches the current chain endpoint • Bulge recording Stores bulge values at the correct vertex indices for each ARC encountered during reconstruction • Polyline builder Constructs an LWPOLYLINE using addLightWeightPolyline with transformed planar coordinates • Clean-up Deletes original REGION and exploded segments after building the new polyline
Functionalities:
• Automatic REGION selection No need to pick objects — all REGIONs are processed automatically • Topology reconstruction Correctly orders exploded segments into a clean closed loop • Arc bulge preservation Converts arcs into bulges for accurate curve representation in LWPOLYLINE format • Normal and elevation restoration Preserves the REGION’s original 3D plane orientation • Deletion of intermediate entities Exploded parts and original REGION are removed to keep drawing tidy • Undo support Protected by an undo mark for safe rollback of the entire conversion • Robust endpoint matching Ensures proper polyline closure even when geometry contains reversed or unordered segments
Result:
• Polyline output Each REGION is converted into a clean closed LWPOLYLINE that accurately follows the REGION perimeter • Curvature preservation All arcs inside the REGION become proper polyline bulges, maintaining geometric fidelity • Consistent segment order The exploded segments are automatically sorted to produce a continuous, gap-free outline • Cleanup Original REGION objects and intermediate exploded entities are deleted to avoid clutter • Final geometry The resulting LWPOLYLINE is closed, planar, properly oriented, and ready for further use such as hatching, offsetting, area calculations, or contours
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
