SelectAll example

SelectAll example
 1# this example creates a rectangle in the active block and ensures that they are
 2# deselected. all entities in the active block are then selected
 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 a position in the active block
16    ab.move_ad(0, 0)
17
18    # create a local variable for the rectangle size
19    rectangle_size = 100
20
21    # create a line
22    line1 = ab.lined(rectangle_size, 0)
23    line2 = ab.lined(0, rectangle_size)
24    line3 = ab.lined(-rectangle_size, 0)
25    line4 = ab.lined(0, -rectangle_size)
26
27    # check the lines were created
28    if not line1 is None and not line2 is None and not line3 is None and not line4 is None:
29
30        # ensure that all the lines are deselected
31        line1.selected = 0
32        line2.selected = 0
33        line3.selected = 0
34        line4.selected = 0
35
36        # select all visible entities in the active block
37        ab.select_all()