DuplicateToSelectedLayer

Short description

  • DuplicateToSelectedLayer — duplicate selected entities onto a chosen target layer via a simple DCL layer picker, then bring the copies to front and preselect them
  • Remembers the last chosen layer and defaults the dialog selection accordingly
  • Uses COPY with zero displacement to create duplicates in place, then CHPROP + DRAWORDER on the new entities
duplicatetoselectedlayer 001.1

Command:

  • DuplicateToSelectedLayer

Description:

  • Prompts the user to select entities to duplicate (any multi-selection method), then opens a DCL dialog to choose the target layer from a list of non-Xref layers.
  • Defaults the layer selection to the last used target layer stored in DuplicateToLayer_LastLayer when it exists in the current drawing.
  • On OK, temporarily switches CLAYER to the target layer, runs COPY with a base point of 0,0 and a displacement of 0,0 (duplicate-in-place), then captures the newly created entities via ssget "_P".
  • Applies the target layer to the copied entities using CHPROP, brings them to the front using DRAWORDER, sets them as the current selection, and restores the original current layer.

Helper function: (if any)​

  • Non-Xref layer enumeration — gathers layer names from the document’s Layers collection and excludes names matching *|*.
  • Last layer persistence — reads/writes DuplicateToLayer_LastLayer via getenv / setenv for default dialog selection.
  • ssget "_P" — retrieves the “previous selection set” after COPY to identify the newly duplicated entities for subsequent operations.

Functionalities:

  • Select source entities — prompts ssget to capture the objects to duplicate; exits with a message if none selected.
  • Build layer list — enumerates all layers, removes Xref-dependent layers (*|*), sorts alphabetically, and populates a DCL popup_list.
  • Dialog defaulting — if the stored last layer exists in the list, preselects it; otherwise defaults to the first entry.
  • Temporary DCL lifecycle — writes a temp .dcl file, loads it, runs the dialog, unloads it, and deletes the file.
  • Duplicate-in-place — saves current CLAYER, sets CLAYER to the target, then runs _.COPY with base/displacement 0,0 to create duplicates without moving them.
  • Capture new entities — uses ssget "_P" to get the copied entities produced by the COPY command.
  • Assign to target layer — runs _.CHPROP on the copied entities with property LA set to the chosen layer name.
  • Bring to front — runs _.DRAWORDER on the copied entities with option _Front to adjust display order.
  • Preselect result — calls sssetfirst to make the duplicated entities the current selection for immediate follow-on operations.
  • Restore state — restores the original current layer and prints a summary including the count of duplicated entities and the target layer name.

Result:

  • The user selects entities, chooses a target layer from a dialog, and the routine duplicates the entities in place onto that layer.
  • The copied entities are forced to the chosen layer, moved to the front of draw order, and left preselected for convenience.
  • If the user cancels the dialog or selects nothing, nothing is changed and an informational message is printed; the last chosen layer is remembered when OK is used.

Images, animations etc.

duplicatetoselectedlayer 001.1
duplicatetoselectedlayer 001
duplicatetoselectedlayer 002
duplicatetoselectedlayer 003
duplicatetoselectedlayer 004
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
Tags: Layers
Tags: Layers
0
Would love your thoughts, please comment.x
()
x