MirrorAboutAxis¶
MirrorAboutAxis¶
1# This example shows the use of the matrix MirrorAboutAxis function
2
3# Check that there is an active drawing
4ad = impact.active_drawing
5if ad.isNone():
6 impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
7else:
8
9 # Create a matrix for the transformation
10 m = impact.creator.matrix()
11
12 # Create some vectors
13 v1 = impact.creator.vector(0,0)
14 v2 = impact.creator.vector(20,40)
15 v3 = impact.creator.vector(20,20)
16 v4 = impact.creator.vector(30,20)
17
18 # Draw the diagonal line, showing the mirror axis
19 active_block.move_a(v1)
20 line1 = active_block.line_a(v2)
21
22 # Draw the horizontal line
23 active_block.move_a(v3)
24 line2 = active_block.line_a(v4)
25
26 # Create the mirror transformation matrix using the two points used for the diagonal line
27 m.mirror_about_axis(v1, v2)
28
29 # Perform the transformation on line2
30 line2.transform(m)
31
32 ad.active_window.view_extents()
33
34