DeleteSelected example

DeleteSelected example
 1# this example creates 3 lines, the last two are selected and then deleted.
 2# note that a sub block cannot be emtpy.
 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    # ensure no entities are selected
16    ab.select_none()
17
18    # ensure new entities are not selected
19    ab.auto_select = 0
20
21    # move to the origin of the active block
22    ab.move_ad(0, 0)
23
24    # create a line
25    ab.line_ad(100, 0)
26
27    # automatically select new entities
28    ab.auto_select = 1
29
30    # create a line
31    ab.line_ad(200, 0)
32
33    # create a line
34    ab.line_ad(300, 0)
35
36    # delete selected entities in the active block
37    ab.delete_selected()
38
39
40
41
42