LineAd example (Python)¶
LineAd example (Python)¶
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 position
19 positionX = 100
20 positionY = 100
21
22 # create a line
23 line1 = ab.line_ad( positionX, positionY )
24
25 # check the line was created
26 if not line1.isNone():
27
28 # display the length of the line in the output toolbox
29 impact.gui.output_toolbox.add(line1.length)