Creating a new block

Creating a new block
 1# this example creates 4 lines and creates a block from them
 2
 3# check there is an active drawing
 4if impact.active_drawing.isNone():
 5
 6    # display a message in the output toolbox
 7    impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
 8
 9else:
10
11    # create a local variable for the active block
12    ab = impact.active_drawing.active_layer.active_block
13
14    # ensure no existing entities are selected
15    ab.select_none()
16
17    # automatically select new entities
18    ab.auto_select = 1
19
20    # move to the origin of the active block
21    ab.move_ad(0, 0)
22
23    # draw some geometry
24    ab.lined(100, 0)
25    ab.lined(0, 100)
26    ab.lined(-100, 0)
27    ab.lined(0, -100)
28
29    # stop automatically selecting new entities
30    ab.auto_select = 0
31
32    # create a new block from the selected entities in the active block
33    ab.block("Block 1", "description", ipBlockPosition.bpLeft)
34