DimensionAligned example¶
DimensionAligned example¶
1# this example creates 4 aligned dimensions
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 some local variables for point1, point2 and the projectionlength
15 p1 = impact.creator.vector(0,0)
16 p2 = impact.creator.vector(0,100)
17 projection_length = 20
18
19 # create an aligned dimension projecting to the left and the dimension
20 # text on the inside
21 ab.dimension_aligned(p1, p2, projection_length, ipProjectionSide.psLeft, ipDimensionTextMode.dtmInside)
22
23 # create an aligned dimension projecting to the right and the dimension
24 # text on the inside
25 ab.dimension_aligned(p1, p2, projection_length, ipProjectionSide.psRight, ipDimensionTextMode.dtmInside)
26
27 # move the projection points along the X axis
28 p1.x = p1.x + 50
29 p2.x = p2.x + 50
30
31 # create an aligned dimension projecting to the left and the dimension
32 # text on the outside
33 ab.dimension_aligned(p1, p2, projection_length, ipProjectionSide.psLeft, ipDimensionTextMode.dtmOutside)
34
35 # create an aligned dimension projecting to the right and the dimension
36 # text on the outside
37 ab.dimension_aligned(p1, p2, projection_length, ipProjectionSide.psRight, ipDimensionTextMode.dtmOutside)
38
39 # view the extents
40 impact.gui.active_window.view_extents()
41
42
43
44
45