Selecting lines

Selecting lines
 1# this example creates a rectangle in the active block and selects some
 2# of the lines of the rectangle
 3if impact.active_drawing.isNone():
 4
 5    # display a message in the output toolbox
 6    impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
 7
 8else:
 9
10    # create a local variable for the active block
11    ab = impact.active_drawing.active_layer.active_block
12
13    # move to the origin in the active block
14    ab.move_ad(0, 0)
15
16    # create a local variable for the rectangle size
17    rectangle_size = 100
18
19    # create a line
20    line1 = ab.lined(rectangle_size, 0)
21    line2 = ab.lined(0, rectangle_size)
22    line3 = ab.lined(-rectangle_size, 0)
23    line4 = ab.lined(0, -rectangle_size)
24
25    # check the lines were created
26    if not line1 is None and not line2 is None and not line3 is None and not line4 is None:
27
28        # ensure that all the lines are deselected (auto select may be on)
29        line1.selected = 0
30        line2.selected = 0
31        line3.selected = 0
32        line4.selected = 0
33
34        # create an IRect
35        r = impact.creator.rect(0,50,100,100)
36
37        # select some lines
38        ab.select_window(r)