Line example¶
Line example¶
1# this example creates a line in the active block and displays its length
2# in the output toolbox
3
4# check there is an active drawing
5if impact.active_drawing.isNone():
6
7 # display a message in the output toolbox
8 impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
9
10else:
11
12 # create a local variable for the active block
13 ab = impact.active_drawing.active_layer.active_block
14
15 # move to the origin of the active block
16 ab.move_ad(0, 0)
17
18 # create a local variable for the offset
19 offset = impact.creator.vector(100,100)
20
21 # create a line
22 line1 = ab.line(offset)
23
24 # check the line was created
25 if line1 is not None:
26
27 # display the length of the line in the output toolbox
28 impact.gui.output_toolbox.add(line1.length)