Region2Polyline

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 markarcbulge 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 arcsSegment ordering scan Reassembles segments by repeatedly finding the next segment whose start or end matches the current chain endpointBulge recording Stores bulge values at the correct vertex indices for each ARC encountered during reconstructionPolyline builder Constructs an LWPOLYLINE using addLightWeightPolyline with transformed planar coordinatesClean-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 automaticallyTopology reconstruction Correctly orders exploded segments into a clean closed loopArc bulge preservation Converts arcs into bulges for accurate curve representation in LWPOLYLINE formatNormal and elevation restoration Preserves the REGION’s original 3D plane orientationDeletion of intermediate entities Exploded parts and original REGION are removed to keep drawing tidyUndo support Protected by an undo mark for safe rollback of the entire conversionRobust 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 perimeterCurvature preservation All arcs inside the REGION become proper polyline bulges, maintaining geometric fidelityConsistent segment order The exploded segments are automatically sorted to produce a continuous, gap-free outlineCleanup Original REGION objects and intermediate exploded entities are deleted to avoid clutterFinal 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.

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="Region2Polyline">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: Region2Polyline</Bold>
<LineBreak/>
<Hyperlink>AI+https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bypass-user-selection-in-lisp-to-convert-region-to-polyline/m-p/8169231#M101570</Hyperlink>
<LineBreak/>
<Bold>Description</Bold><LineBreak/>
This AutoLISP routine <Span Foreground="DarkRed">Region2Polyline</Span> converts selected REGION entities into closed lightweight polylines by exploding and rebuilding them with line and arc segments.<LineBreak/>
Written by <Span Foreground="DarkRed">Gilles Chanteau</Span> on 01/01/07.<LineBreak/>

<Bold>Functionalities:</Bold><LineBreak/>
• Command syntax: <Span Foreground="DarkRed">Region2Polyline</Span>.<LineBreak/>
• Prompts the user to select REGION objects in the drawing.<LineBreak/>
• Explodes each REGION into its primitive line and arc components.<LineBreak/>
• Rebuilds the exploded geometry into a closed lightweight polyline.<LineBreak/>
• Handles arc segments by calculating bulge values (<Span Foreground="DarkRed">arcbulge</Span>) to preserve curvature.<LineBreak/>
• Deletes the original REGION objects once converted.<LineBreak/>
• Ensures the new polyline is closed and placed in the correct drawing space (ModelSpace or PaperSpace depending on CVPORT).<LineBreak/>
• Groups the operation into an undo mark for rollback.<LineBreak/>

<Bold>Key Features:</Bold><LineBreak/>
• Converts REGIONS back into editable polylines without loss of arcs.<LineBreak/>
• Works with both ModelSpace and PaperSpace contexts.<LineBreak/>
• Uses robust geometric matching of endpoints to reconstruct polylines.<LineBreak/>
• Preserves geometric accuracy of arcs using calculated bulge factors.<LineBreak/>

<Bold>Function Syntax</Bold><LineBreak/>
• <Span Foreground="DarkRed">Region2Polyline</Span><LineBreak/>

<Bold>Typical Workflow</Bold><LineBreak/>
• Run <Span Foreground="DarkRed">Region2Polyline</Span>.<LineBreak/>
• Select one or more REGION objects.<LineBreak/>
• The program explodes them, rebuilds the edges as closed lightweight polylines, and deletes the original REGIONs.<LineBreak/>
• The resulting polyline(s) are ready for editing, measuring, or further CAD operations.<LineBreak/>


</TextBlock>
            


</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>



Additional info:

Share this page:

Leave a Reply

Page Tag: 🏷️ Autocad Lisps

  • Region2Polyline

    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…

  • Lengthen

    Short description🧩 Lengthen is an enhanced Double Extend style AutoLISP tool for extending multiple selected LINE ARC LWPOLYLINE and POLYLINE entities at both ends. 🎛️ The DCL first workflow includes object picking highlighting separate Start and End extension values a Both Ends Slot option dynamic drag preview Apply Undo Debug OK and Cancel. 🧪 The…

  • CopySelection

    Short description Purpose: Duplicate only a chosen segment of a LWPolyline between two picked points and generate it on a selected layer Supported objects: Single LWPOLYLINE only Usage style: Extract partial polyline segments and place them on a different layer using a filterable layer picker dialog Command: Command name: CopySelection How to run: Type COPYSELECTION…

  • CloseParalelPolylines

    Short description Purpose: Automatically connect two open or parallel-like entities and merge them into one continuous polyline Supported objects: LWPOLYLINE, LINE, ARC, SPLINE Usage style: Cleanup or closing gaps between two aligned open objects Command: Command name: CloseParallelPolylines How to run: Type CLOSEPARALLELPOLYLINES and press Enter User prompt: Select two open polylines, arcs, splines, or…

  • DuplicateLayouts_00

    Short description Shows a DCL dialog to choose paper-space layouts and specify how many copies to create for each, then duplicates the selected layouts using the LAYOUT command. Provides a summary list where selected layouts and their copy counts can be reviewed and removed before running the duplication. Command: Command: DuplicateLayouts Description: Creates a temporary…

  • AnnoAllOn

    Short description Opens a DCL picker to choose Model and Layout tabs, then sets ANNOALLVISIBLE to 1 on the selected tabs. Includes quick selection controls for All and None before applying changes. Command: Command: AAON Description: Generates a temporary DCL dialog at runtime listing all tabs, including Model, with multi-select enabled. On confirmation, switches to…

  • Page setups all layouts – to be updated / new page

    Short description Comming soon … Command: Comming soon … Description: Comming soon … Helper function: (if any)​ Comming soon … Functionalities: Comming soon … Result: Comming soon … Images, animations etc. Lisp code: Expand Code ⬇ Select Code Copy Code Comming soon … Additional info: Based on / Source code: Open Website Share this page:

  • TitleBlocksTools

    Short description Title Blocks Tools – Unified Menu System Comprehensive dialog-based interface for exporting and updating titleblock attributes via CSV with integrated help, file management, and reload utilities. Command: Commands: TitleBlocksTools, EXPTBCSV_EXPORT, UTB2 Description: This integrated toolset combines CSV export and import functionality for titleblock attribute management: Main Menu Dialog provides radio button selection between…

  • Zoom2Layer

    Short description Displays a filterable layer selection dialog and then zooms the view to the extents of all objects on the chosen layer. Supports picking a layer directly from a selected object in the drawing and remembers the last filter used. Command: Command: Zoom2Layer Description: Builds a list of layers that are visible and unfrozen,…

  • PurgeUnusedLayers

    Short description🧹 PurgeUnusedLayers is an AutoCAD AutoLISP cleanup utility with an embedded DCL dialog for scanning and deleting unused drawing layers. 🔒 It protects key layers such as 0 and DEFPOINTS, can skip Xref layers, and lets users purge selected layers or all detected unused layers. Command:🚀 Main command: PURGEUNUSEDLAYERS 🧩 Load the LSP in…