Arc Sweep Angle (Python)

Arc Sweep Angle (Python)
 1# This example creates an arc and displays the sweep angle of the arc in the
 2# output toolbox. The sweep angle of the arc is then modified and displayed
 3# again in the output toolbox.
 4
 5# Create a local variable for the output toolbox
 6ot = impact.gui.output_toolbox
 7
 8# Clear the output toolbox
 9ot.clear()
10
11# Create a local variable for the active drawing
12ad = impact.active_drawing
13
14# check there is an active drawing
15if ad.isNone():
16
17    # display a message in the output toolbox
18    ot.add("Unable to continue: there is no active drawing")
19
20else:
21
22    # create a local variable for the active block
23    ab = ad.active_layer.active_block
24
25    # move to the origin of the active block
26    ab.move_ad(0, 0)
27
28    # create a local variable for the radius
29    radius = 50
30
31    # create a vector for the offset
32    offset = None
33    try:
34        offset = impact.creator.vector(radius,radius)
35    except Exception as exc:
36        pass
37    impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
38
39    # create a clockwise large arc
40    arc1 = None
41    try:
42        arc1 = ab.arc( offset, radius, 0, 1 )
43    except Exception as exc:
44        pass
45    impact.gui.output_toolbox.add(f"Failed to create object via ab.arc(): {exc}")
46
47    # display the sweep angle of the arc in the output toolbox
48    ot.add(arc1.sweep_angle)
49
50    # modify the sweep angle of the arc
51    arc1.sweep_angle = arc1.sweep_angle + 90
52
53    # display the sweep angle of the arc in the output toolbox
54    ot.add(arc1.sweep_angle)