Copying a layer (Python)

Copying a layer (Python)
 1# for this example you need two impact.drawings open
 2# the active layer of the first drawing is copied
 3# to the second drawing
 4
 5# get the active layer of the first drawing
 6sourceLayer = impact.drawings.item(1).active_layer
 7
 8# get the second drawing
 9destinationDrawing = None
10try:
11    destinationDrawing = impact.drawings.item(2)
12except Exception as exc:
13    impact.gui.output_toolbox.add(f"Failed to create object via impact.drawings.item(): {exc}")
14
15# do the copy
16newLayer = sourceLayer.copy_to_drawing( destinationDrawing, "" )
17
18if not newLayer.isNone():
19    impact.gui.output_toolbox.add(newLayer.full_name)
20else:
21    impact.gui.output_toolbox.add("the copy failed")