LineAd example

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