ArcA example

ArcA example
 1# this example creates 4 arcs all with the same radius in the active block
 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    # move to the origin of the active block
15    ab.move_ad(0, 0)
16
17    # create a local variable for the radius
18    radius = 50
19
20    # create a vector for the offset
21    position = impact.creator.vector()
22
23    # create a clockwise large arc
24    ab.arc_a(position, radius, 0, 0)
25
26    # change the position
27    position.x = position.x + 100
28    position.y = position.y + 100
29
30    # create an anti-clockwise large arc
31    ab.arc(position, radius, 1, 0)
32
33    # change the position
34    position.x = position.x + 100
35    position.y = position.y + 100
36
37    # create a clockwise small arc
38    ab.arc(position, radius, 0, 1)
39
40    # change the position
41    position.x = position.x + 100
42    position.y = position.y + 100
43
44    impact.gui.output_toolbox.add(position.to_string())
45
46    # create an anti-clockwise small arc
47    ab.arc(position, radius, 1, 1)