Short description
Sort / Purpose: Create a new polyline segment copied between two picked points on an existing LWPOLYLINE, place it on a chosen layer, and optionally extend, rotate, move, and generate multiple offset copies via an interactive dialog with Apply and Undo.
• Scope: Works only on a selected LWPOLYLINE, extracting the portion between two points along the polyline and building a new, separate polyline from that segment.
• Goal: Speed up creation of repeated pipe or band segments with controlled layer assignment, geometric extension at ends, rotation, perpendicular distance, and multiple parallel offsets using presets.

Command:
Command name: CopySelection
How to run: Load the LISP file, then type CopySelection in the command line and press Enter.
• Entity selection: First select one LWPOLYLINE when prompted “Select LWPolyline”; other entity types are rejected.
• Point selection: Specify the first and second points on that polyline; the routine projects those picks onto the polyline and uses the segment between them as the base for the new geometry.
• Dialog control: A dialog named PLDupeLayerEx is shown where you choose the target layer, filter layers by name, enable or disable Extra options, and use Apply, Undo, OK, or Cancel to control the operation.
Description:
• Polyline and points: After you choose an LWPOLYLINE, the routine asks for two points along it, snaps them to the closest points on the curve, and ensures they are not identical before continuing.
• Segment extraction: Uses curve parameters at the two picked locations to slice the source polyline between those parameters, reconstructing a new vertex list that represents only the chosen segment (including bulges and widths).
• Header cloning: Copies the original polyline’s non vertex DXF data, forces the new polyline onto the chosen target layer, and clears the closed flag so the result is an open segment.
• Layer dialog: Builds a temporary DCL file that provides a text filter for layer names, a popup list of matching layers, a button to pick a layer from an existing object, and a toggle to enable or disable Extra transform options.
• Layer filtering and pick: Collects all non xref layers, sorts them, filters them dynamically as you type in the filter box, and lets you optionally pick an entity in the drawing to adopt its layer as the target.
• Extra options group: When Extra is enabled, the dialog exposes rotation start or end toggle, rotation angle, perpendicular distance, offset style presets, numeric offset, offset copy count, and numeric extension at start and end.
• Extension at ends: The extend-ends helper extends the first and last segments of the new polyline by independent distances extS and extE along their segment directions, updating coordinates through COM.
• Rotation and distance: Computes a unit direction from the first pick to the second, then rotates the new polyline around the chosen base point (start or end) by the given angle, and moves it perpendicular to that direction by the specified distance.
• Offset copies: Creates additional parallel copies of the transformed polyline, spaced by the offset distance along the normal direction, up to the specified offset count; the offset value can be auto filled from presets like DN110, KK I to KK IV.
• Persistent settings: Stores the last used layer and filter string in environment variables so that the next run of the command remembers which layer and filter you used previously.
• Apply and Undo loop: Wraps operations in a global UNDO group, marks the undo stack before each Apply, and supports stepping back one Apply at a time when you press Undo, without closing the dialog.
• Finalization logic: If you never used Apply or Undo, pressing OK performs a single geometry creation using current dialog values; if you cancel, all Apply actions in this session are undone before closing the group.
Helper function: (if any)
Geometry helpers:
• tan: Simple tangent function used when computing bulge values for polyline vertex reconstruction.
• LM:LWVertices: Extracts vertices of a lightweight polyline into a structured list containing position, start width, end width, and bulge for each vertex, used by the PLDUPE style segment slicing logic.
• extend-ends: Uses VLA coordinates to extend the first and last segments of the new LWPOLYLINE by extS and extE along their unit direction vectors, handling both two vertex and multi vertex polylines.
Segment creation core:
• CS:MakeGeometry: Main builder that slices the original LWPOLYLINE between two curve parameters, builds a new open polyline on the chosen layer, then applies optional extension, rotation, distance move, and offset copy generation when Extra is enabled.
Dialog and state helpers:
• get-all-layers: Iterates over the drawing’s layer table via COM, collects all non xref layers into a sorted list for the layer popup.
• update-layer-list: Filters the layer list by the current filter string, rebuilds the popup content, and selects either the picked layer, last used layer, or the first match as current choice.
• set-extra-mode: Enables or disables all Extra related tiles (rotation, distance, offsets, extension values) depending on the Extra toggle, greying them out when Extra is off.
• CS:read-values: Reads all current dialog fields (filter, layer, Extra flag, rotation choice, angle, distance, offset, offset count, and extension values), converts them to numbers, clamps offset count to non negative integers, and updates environment variables for filter and layer.
• Offset presets: The offset type popup selects among DN110 and KK variants, and an action tile maps each choice to a predefined numeric offset value written back into the offset edit box.
Undo session control:
• applyCount and flags: Tracks how many times Apply has been used, whether there is any applied geometry present, and whether the user has interacted with Apply or Undo, to decide how OK and Cancel should behave regarding undoing or keeping changes.
Functionalities:
• Segment duplication: Quickly duplicates only a chosen portion of an LWPOLYLINE between two points, instead of copying and trimming manually.
• Layer targeting: Lets you send the new polyline and its copies directly onto a specific layer chosen from a filtered list or from a picked object, keeping layer structure organized.
• Optional advanced transforms: When Extra is on, you can extend ends, rotate the new polyline around the start or end point, shift it perpendicular to its own direction, and generate several parallel copies at fixed offset distances.
• Preset offset library: Built in presets (DN110, KK I to KK IV) automatically set offset distances that match typical pipe or trench sizes, saving you from repeatedly typing standard values.
• Interactive Apply and Undo: You can iteratively test different settings: Apply to create geometry, Undo to remove the last created batch, adjust dialog values, and repeat, all on the same source polyline selection.
• Robust cancellation: If you close the dialog or choose Cancel after one or more Apply actions, the routine automatically undoes all those actions so the drawing returns to its original state.
• Single step final undo: When you finish with OK, all geometry created in this session remains, but the entire operation is enclosed in an UNDO group so one undo command removes everything if needed.
Result:
Result: A new polyline segment is created from the selected portion of the original LWPOLYLINE, placed on the chosen layer, and optionally extended, rotated, shifted, and replicated as multiple offset copies according to your dialog settings.
• Efficient profile building: Complex pipe or band arrangements along an alignment can be generated from a single base polyline, with each functional run duplicated and positioned with precise numeric control rather than manual edits.
• Consistent offsets and angles: Repeated elements share the same extension, rotation, distance, and offset parameters, giving your layout a uniform and standards compliant appearance.
• Safe experimentation: Apply and Undo inside the dialog let you experiment with different combinations of offsets, angles, and extension distances, knowing that Cancel can revert everything and OK will keep the final configuration in a single undo block.
• Workflow memory: The command remembers your last layer and filter, so subsequent runs in the same project feel streamlined with minimal repetitive input.
Copy code:
Images, animations etc.
Log in to download.
Log in
Log in
Additional info:
Based on / Source code:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
