GetAreaAndLengthOfSelected example¶
GetAreaAndLengthOfSelected example¶
1# this example displays the length and area of selected entities in the output
2# toolbox
3
4# check there is an active drawing
5if impact.active_drawing.isNone():
6
7 # display a message in the output toolbox
8 impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
9
10else:
11
12 # create a local variable for the active block
13 ab = impact.active_drawing.active_layer.active_block
14
15 # select all visible entities in the active block
16 ab.select_all()
17
18 # create a local variable for the Recurse option
19 recurse = 1
20
21 # create local variables to store the results
22 outer_area = None
23 inner_area = None
24 outer_perimeter = None
25 inner_perimeter = None
26
27 # get the area and length of selected entities in the active block
28 ab.get_area_and_length_of_selected(outer_area, inner_area, outer_perimeter, inner_perimeter, recurse)
29
30 # create a local variable for the output toolbox
31 impact.output_toolbox = impact.gui.output_toolbox
32
33 # clear the output toolbox
34 impact.output_toolbox.clear()
35
36 # display the results in the output toolbox
37 impact.output_toolbox.add("Outer Area: " + str(outer_area))
38 impact.output_toolbox.add("Inner Area: " + str(inner_area))
39 impact.output_toolbox.add("Outer Perimeter: " + str(outer_perimeter))
40 impact.output_toolbox.add("Inner Perimeter: " + str(inner_perimeter))