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 and press Enter Prompts sequence: Select LWPolyline → Specify 1st Point → Specify 2nd Point → Choose Layer Selection rules: Command stops if selected object is missing or not a LWPOLYLINE

Description:

The user selects an LWPolyline and then two points projected onto its geometry to define the segment to duplicate. A dialog appears allowing layer filtering, picking from a list, or selecting an object in the drawing to adopt its layer. The code calculates curve parameters between the two points, reconstructs only that portion with widths and bulges, and creates a new LWPolyline on the chosen layer.

Helper function: (if any)​

tan Computes tangent of an angle while avoiding division by near-zero cosine valuesLM:LWVertices Extracts LWPolyline vertex data such as point, widths, and bulgeget-all-layers Collects all non-xref layers, sorts them, and prepares them for the layer pickerupdate-layer-list Updates layer popup list in the dialog according to the typed filterDCL builder Creates a temporary dialog file containing filter input, layer list, pick-layer button, and OK/Cancel controls

Functionalities:

Polyline validation Ensures the selected object is a LWPOLYLINEPoint projection Snaps the picked points to the closest polyline points before using themDistinct point enforcement Rejects overlapping points and forces user to choose a valid second pointParameter order correction Swaps start and end parameters when reversed by selectionLayer dialog with memory Recalls last filter and layer using stored environment variablesLayer filtering Dynamically filters layer names using wildcard matchingPick layer from drawing Lets the user click any object to inherit its layerSegment extraction Reconstructs only the portion between the two parametric points including widths and bulgesNew polyline creation Builds a fresh LWPolyline with original properties but on the new layerCleanup Removes temporary DCL file after dialog closesCancellation handling Stops with a message if no valid layer is chosen

Result:

Segment duplication A new LWPolyline reproducing only the selected portion of the original is createdLayer assignment The new polyline is placed on the chosen layer without altering the original objectWorkflow benefit Enables quick extraction of partial runs for detailing, highlights, or separate layer controlSession persistence Stores last used filter and layer to speed up future usage

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