Creating a new layer

Creating a new layer
 1# This example creates a new 'ONE_UP' layer called 'my new layer' based upon
 2# the active layer in the active drawing and outputs the name of the new layer
 3# to the output toolbox.
 4
 5# Create a local variable for the active drawing
 6ad = impact.active_drawing
 7
 8# Check that there is an active drawing
 9if not ad.isNone():
10
11    # Create a local variable for the template layer
12    template_layer = ad.active_layer
13
14    # Define some parameters to pass to the ILayers.add() method
15    new_layer_name = "my new layer"
16    new_layer_type = "one_up"
17
18    # Create a new layer
19    new_layer = ad.layers.add(new_layer_name, new_layer_type, template_layer)
20
21    # Display the name of the new layer in the output toolbox
22    impact.gui.output_toolbox.add(new_layer.full_name)
23
24else:
25
26    # Display a message in the output toolbox
27    impact.gui.output_toolbox.add("unable to continue: no active drawing")