Creating a layer (Python)¶
Creating a layer (Python)¶
1# This example creates a layer for the active drawing
2
3# Create a local variable for the impact impact.gui object
4g = impact.gui
5
6# Create a local variable for the output toolbox
7ot = g.output_toolbox
8
9# clear the output toolbox
10ot.clear()
11
12# check there is an active drawing
13if impact.active_drawing.isNone():
14
15 # display an error message in the output toolbox
16 ot.add("Unable to continue: there is no active drawing")
17
18else:
19
20 # Attempt to create a layer
21 l = g.tools.create_layer()
22
23 # Check a layer was created
24 if not l.isNone():
25
26 ot.add(l.full_name)
27
28 else:
29
30 ot.add("A layer was not created")