DimensionVertical example (Python)

DimensionVertical example (Python)
 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    points[0] = impact.creator.vector(0,0)
18    points[1] = impact.creator.vector(0,21)
19    points[2] = impact.creator.vector(0,40)
20    points[3] = impact.creator.vector(0,60)
21
22    # create some local variables to store the dimensions returned,
23    # projection length, projection side, etc.
24    dimensions = None
25    projectionLength = 10
26    projectionSide = ipProjectionSide.psLeft
27    dimensionMode = ipDimensionMode.dmSingle
28
29    # create the vertical dimensions
30    dimensions = ab.dimension_vertical( points, projectionLength, projectionSide, dimensionMode )
31
32    # clear the output toolbox
33    impact.gui.output_tool_box.clear()
34
35    # check that some dimensions were returned
36    if isinstance(dimensions):
37
38        # iterate all the created dimensions
39        for i in range(0, len(dimensions) - 1 + 1):
40
41            # display the extents of the dimension in the output toolbox
42            impact.gui.output_toolbox.add(dimensions(i).extents.to_string()       )