DimensionHorizontal example¶
DimensionHorizontal example¶
1# This example creates 3 horizontal dimensions and displays their values
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 # create an array of points to dimension
15 points = [None] * 4
16
17 points[0] = impact.creator.vector(0,0)
18 points[1] = impact.creator.vector(21,0)
19 points[2] = impact.creator.vector(40,0)
20 points[3] = impact.creator.vector(60,0)
21
22 # create some local variables to store the dimensions returned,
23 # projection length, projection side, etc.
24 projection_length = 10
25 projection_side = ipProjectionSide.psLeft
26 dimension_mode = ipDimensionMode.dmSingle
27
28 # create the horizontal dimensions
29 dimensions = ab.dimension_horizontal(points, projection_length, projection_side, dimension_mode)
30
31 # Wrap variant return items with Impact.py wrapper
32 if dimensions is not None:
33 dimensions = [ILinearDimension(item) for item in dimensions]
34
35 # check that some dimensions were returned
36 if dimensions:
37 for dim_ent in dimensions:
38 impact.gui.output_toolbox.add("Dimension value is " + str(dim_ent.expression_value))
39
40