Function Syntax: CopySelection / csel Version: 1.0 Date: 30.06.2026 3:16:02PM AI + https://www.theswamp.org/index.php?topic=59415.0 Description 🧩 CopySelection v8 is an AutoCAD and Civil 3D AutoLISP curve duplication and transformation utility for creating new polyline geometry from selected portions of one or multiple source curves. 🎛️ Its DCL interface combines curve selection layer assignment rotation translation repeated offsets endpoint extension optional parallel closing optional centerline creation Apply Undo OK Cancel and model space interaction. 📐 Supported source curves include LWPOLYLINE LINE ARC and legacy POLYLINE entities. Function Syntax Main command: CopySelection Alias: CSEL SEO Optimized Overview 📍 The user first selects one or more supported curves and then specifies two points that define the source segment to duplicate. 🎯 The curve nearest the first picked point becomes the reference curve and the same picked start and end locations are projected onto every selected curve. 🧬 LINE ARC and legacy POLYLINE source geometry is converted temporarily into lightweight polyline form so the requested segment can be reconstructed. 🎛️ The new geometry can remain on the source layer or be assigned to another non Xref layer selected from a filtered layer list or picked from the drawing. 🔄 Extra mode can rotate the copied segment by a user defined angle around the selected start or end reference and move it laterally by a user defined distance. 📐 Extra 02 performs the extended and shifted workflow without rotation. ➡️ Start plus Left and End plus Right control the rotation reference and side orientation used by the transformation workflow. 📏 Extend Start and Extend End can lengthen the created lightweight polyline before the optional offset copies are generated. 📚 Offset presets include DN110 KK I KK II KK III KK IIIa and KK IV values together with a manually editable offset distance. 🔢 Offset Count can create up to twenty additional parallel copies. 🔗 CloseParallelPolylines can process created polylines in pairs by adding endpoint connectors and joining them through PEDIT. ➗ Create centerline polyline can generate an additional centerline between paired created polylines when the close workflow is enabled. 💾 The routine stores many last used settings with setenv and stores the DCL window position with setcfg. Primary Workflow • Run CopySelection or CSEL. • Click Select Curves and Points and select one or more supported source curves. • Specify the first and second points defining the source curve segment. • Choose source layer or select another target layer. • Configure Extra or Extra 02 rotation distance offset count start extension end extension closing and centerline options. • Use Apply to generate geometry and keep the dialog workflow active. • Use Undo to reverse the previous Apply result. • Use Interact to temporarily hide the dialog for pan zoom and model space navigation. • Use OK to create the final result and close the command. Functionalities Multiple curve selection - supports processing several selected curves with one pair of reference points. Segment extraction - duplicates only the portion between the two projected reference points. LINE and ARC conversion - creates temporary lightweight polyline representations for supported non polyline curves. Legacy POLYLINE conversion - uses CONVERTPOLY Light on a temporary copy before segment generation. Layer filtering - filters the available non Xref drawing layers by name. Pick layer from drawing - reads the layer from a selected drawing object. Use source layer - creates each duplicated segment on its original source layer. Rotation workflow - supports user defined angular rotation in Extra mode. No rotation workflow - Extra 02 applies the transformation logic without angular rotation. Lateral movement - moves created geometry by a user defined perpendicular distance. Repeated offsets - creates multiple additional copies using the selected offset spacing. Offset presets - provides DN and cable channel related preset widths. Endpoint extension - supports independent Start and End extension distances. Parallel polyline closing - adds endpoint connectors and joins created pairs. Optional centerline - creates a centerline for paired created polylines. Apply and Undo - supports iterative generation and rollback while keeping the tool active. Model space interaction - temporarily closes the dialog so the user can pan zoom or navigate. Persistent settings - remembers layer filters transform values options and dialog position. Important Commands and Aspects 🧩 CS:MakeTempLW converts supported source geometry into temporary lightweight polyline form. 🧩 CS:MakeGeometry reconstructs and transforms the requested segment. 🧩 CS:MakeAllGeometry applies the same operation to every selected curve. 🧩 CS:CloseParFromList closes created polyline pairs and optionally generates a centerline. 🧩 PPO-CreateCenterline contains the centerline construction logic. 🧩 LM:LWVertices and bulge helpers preserve straight and curved lightweight polyline segment geometry. Result 🎯 The result is one or more newly created lightweight polyline segments derived from the selected source curve portions. 📐 Depending on the selected options the result can also include rotated shifted extended repeated offset closed parallel and centerline geometry. 🧰 The tool is suitable for repeatable corridor utility cable protection and parallel geometry construction workflows. Important Notes ⚠️ Offset Count is limited to a maximum of twenty copies by the current source. ⚠️ CloseParallelPolylines processes created entities in pairs and only performs the close logic when both members are AcDbPolyline objects. ⚠️ The centerline option is used by the parallel closing workflow rather than as an independent command. ⚠️ The source reports CopySelection v8 when loaded. SEO Keywords 🏷️ AutoCAD, 🏷️ Civil 3D, 🏷️ AutoLISP, 🏷️ CopySelection, 🏷️ CSEL, 🏷️ Polyline copy, 🏷️ Curve segment copy, 🏷️ Parallel offset, 🏷️ Polyline extension, 🏷️ Polyline rotation, 🏷️ Layer assignment, 🏷️ Close parallel polylines, 🏷️ Centerline, 🏷️ DCL, 🏷️ CAD automation Description This AutoLISP program defines the command CopySelection. It prompts the user to select a source LWPOLYLINE and two points on that polyline, then creates a new polyline segment corresponding to the portion between those two points. A DCL dialog lets the user choose the destination layer and optional geometry transformations, including extend, rotate, move, parallel offsets, and an optional post-process to close parallel polylines (and optionally generate a centerline). The dialog supports Apply and Undo actions for iterative creation, and persists settings between runs via environment variables. Primary user workflow - The user runs CopySelection. - The user selects a source LWPolyline in the drawing. - The user specifies a first point and a second point; both are projected to the nearest points on the source polyline so the two points define a polyline segment by station along the curve. - A dialog opens titled Set Layer for New Polyline, allowing configuration of layer and optional extra operations. - The user can: - Click Apply to generate geometry and keep the dialog open for further iterations. - Click Undo to undo the last Apply step. - Click OK to generate geometry once and close the dialog. - Click Cancel to exit without further changes. What the routine creates - A new entity of type LWPOLYLINE representing the portion of the selected source polyline between the two chosen points. - Optionally, additional parallel copies of that new polyline can be created based on offset settings, with a capped count to avoid excessive output. - Optionally, if CloseParallelPolylines is enabled, the routine may add connecting lines and then join objects to form a closed-like boundary from pairs of created polylines, and optionally generate a centerline between each parallel pair. Key functionalitiesExtract a sub-segment from an LWPolyline: - Uses curve parameters at the nearest points to isolate the vertex range between point P and point Q. - Preserves bulge information and widths by reconstructing the polyline vertex list between the parametric stations. - Builds a new LWPOLYLINE with entmakex, and places it on the selected destination layer.Layer selection with filtering: - Builds a list of all non-xref-dependent layers (layers without the pipe character). - Provides a filter edit box and a popup list of matching layers. - Provides Pick Layer From Drawing to read the layer of a selected object and reuse it as the chosen layer. - Provides Use Source Layer to force output to the layer of the selected source polyline and disable layer selection controls.Extra geometry processing controlled by the Extra toggle: - Extend start and end for the new LWPOLYLINE using a bulge-aware polyline extension routine. - Rotate the new polyline around either the start or end point, by an angle in degrees. - Translate the polyline perpendicular to its direction (left or right) by a distance value. - Create multiple parallel copies by repeatedly copying and moving the entity by the offset step, up to an enforced limit.Offset presets via popup list: - Selecting a preset updates the Offset edit box to a predefined numeric value, allowing quick standard spacing selection.Apply / Undo iterative loop: - Apply creates geometry once, regenerates the drawing, optionally runs parallel closing, then reopens the dialog for continued work. - Undo executes UNDO Back to revert the last created geometry step.Close parallel polylines and optional centerline: - When enabled, created entities are processed in pairs: for each pair of open polylines, the routine can optionally create a centerline, then connects corresponding endpoints with two new LINE entities and uses PEDIT multiple join to form one joined object. - Centerline generation uses loft and intersect operations and may use Express Tools flattening when available, otherwise it falls back to a move-flatten method. Dialog controls and what they affect - Filter by Name: filters the layer list by wildcard matching. - Matching Layers: popup list used to select the output layer (disabled if Use Source Layer is enabled). - Use Source Layer: forces layername to the source polyline layer and disables manual layer selection and pick-layer button. - Pick Layer From Drawing: temporarily closes the dialog so the user can click an entity; its layer becomes the selected layer for next dialog cycle. - Extra: enables or disables all rotate, move, extend, offset, and closing options as a group. - Rotate group: - Start or End: sets the rotation base point (P or Q). - Angle (deg): rotation angle applied to the new entity. - Side group: - Left or Right: controls direction of perpendicular translation and direction of repeated offsets. - Distance: translation magnitude perpendicular to the polyline direction. - Offset group: - Offset: spacing step for additional copies of the new polyline. - Offset Count: number of additional copies to create, constrained to a maximum of 20. - Offsettype: preset selector that writes predefined values into Offset. - Extension group: - Extend Start, Extend End: applies bulge-aware extension to the created polyline. - Closing and centerline group: - CloseParallelPolylines: triggers the post-process that connects endpoints and joins objects. - Create centerline polyline: controls whether a centerline is attempted between each pair of parallels when closing is enabled. - Action buttons: - Apply: create now, keep dialog open. - Undo: undo last Apply step. - OK: create once and exit. - Cancel: exit without creating further geometry. Persistence and defaults - Settings are persisted using setenv and restored using getenv under keys such as: - PLDUPE_LastLayer, PLDUPE_LastFilter, PLDUPE_UseSourceLayer. - PLDUPE_LastAngle, PLDUPE_LastDistance, PLDUPE_LastOffset, PLDUPE_LastOffCount. - PLDUPE_LastExtS, PLDUPE_LastExtE, PLDUPE_LastExtra. - PLDUPE_LastRot, PLDUPE_LastSide, PLDUPE_CloseParallel, PLDUPE_Centerline. - Centerline option also references a global default variable *PPO_Centerline*, defaulting to true if not previously defined or persisted as disabled. Important commands and internal functions - Command entry point: c:CopySelection. - Geometry creation core: CS:MakeGeometry which constructs the new polyline and optional extra transformations and offsets. - Bulge-aware extension for LWPOLYLINE: CS:ExtendEntity calling LM:dex:extendpoly and LM:lwvertices. - Close-parallel post-process: CS:CloseParFromList which optionally calls PPO-CreateCenterline and then performs PEDIT join operations. - Centerline generator: PPO-CreateCenterline uses AutoCAD commands OFFSET, MOVE, LOFT, INTERSECT, and JOIN and may rely on Express Tools for flattening. - Dialog helpers: update-layer-list, CS:read-values, set-extra-mode, CS:set-layer-mode. Notable constraints and validations - The routine requires the selected object to be LWPOLYLINE; otherwise it exits immediately after selection validation. - The two points must be distinct when projected onto the curve; otherwise the user is re-prompted until they are different. - Offset Count is clamped to the range 0 to 20 to limit the number of generated copies. - Centerline creation has strict checks for UCS, view direction, AutoCAD version, and polyline elevation and normal; if checks fail, centerline is skipped while the rest of the workflow can continue. - The closing operation is wrapped in vl-catch-all-apply so failures do not terminate the main dialog loop; instead a warning is printed.