Copying selected entities to another layer¶
Copying selected entities to another layer¶
1# This example copies a single entity from one layer to another.
2
3# check there is an active drawing
4if impact.active_drawing.isNone():
5 impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
6else:
7
8 # create a local variable for the active layer
9 original_layer = impact.active_drawing.active_layer
10
11 # create a new layer (and makes it active)
12 new_layer = impact.active_drawing.layers.add("new layer", "ONE_UP", original_layer)
13
14 # draw a line
15 new_layer.active_block.move_ad(0, 0)
16 new_layer.active_block.line_ad(100, 0)
17
18 # select all visible entities in the new layer
19 new_layer.active_block.select_all()
20
21 # copy the selected entities from the new layer to the original layer
22 new_layer.active_block.copy_selected_to_layer(original_layer, True)
23
24 # change back to the original layer
25 impact.active_drawing.active_layer = original_layer