ArcAd example

ArcAd 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 two local variables for the position for the offset
21    position_x = 0
22    position_y = 0
23
24    # create a clockwise large arc
25    ab.arc_ad(position_x, position_y, radius, 0, 0)
26
27    # change the position
28    position_x = position_x + 100
29    position_y = position_y + 100
30
31    # create an anti-clockwise large arc
32    ab.arc_ad(position_x, position_y, radius, 1, 0)
33
34    # change the position
35    position_x = position_x + 100
36    position_y = position_y + 100
37
38    # create a clockwise small arc
39    ab.arc_ad(position_x, position_y, radius, 0, 1)
40
41    # change the position
42    position_x = position_x + 100
43    position_y = position_y + 100
44
45    # create an anti-clockwise small arc
46    ab.arc_ad(position_x, position_y, radius, 1, 1)