Arc Length¶
Arc Length¶
1# This example creates an arc and displays the length of the arc in the
2# output toolbox. The length 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 = impact.creator.vector(radius,radius)
33
34 # create a clockwise large arc
35 arc1 = ab.arc(offset, radius, 0, 1)
36
37 # display the length of the arc in the output toolbox
38 ot.add(arc1.length)
39
40 # modify the length of the arc
41 arc1.length = arc1.length * 2
42
43 # display the length of the arc in the output toolbox
44 ot.add(arc1.length)