DimensionVertical example¶
DimensionVertical example¶
1# this example creates 3 vertical dimensions and displays their extents in
2# the output 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 # create an array of points to dimension
16 points = [None] * 4
17
18 points[0] = impact.creator.vector(0,0)
19 points[1] = impact.creator.vector(0,21)
20 points[2] = impact.creator.vector(0,40)
21 points[3] = impact.creator.vector(0,60)
22
23 # create some local variables to store the dimensions returned,
24 # projection length, projection side, etc.
25 dimensions = None
26 projection_length = 10
27 projection_side = ipProjectionSide.psLeft
28 dimension_mode = ipDimensionMode.dmSingle
29
30 # create the vertical dimensions
31 dimensions = ab.dimension_vertical(points, projection_length, projection_side, dimension_mode)
32
33 # Wrap variant return items with Impact.py wrapper
34 if dimensions is not None:
35 dimensions = [ILinearDimension(item) for item in dimensions]
36
37 # clear the output toolbox
38 impact.gui.output_toolbox.clear()
39
40 # check that some dimensions were returned
41 if dimensions:
42
43 # iterate all the created dimensions
44 for i in range(0, len(dimensions) - 1 + 1):
45
46 # display the extents of the dimension in the output toolbox
47 impact.gui.output_toolbox.add(dimensions[i].extents.to_string())
48
49
50
51
52
53