Rotate example (Python)¶
Rotate example (Python)¶
1# this example creates a line in the active block and rotates it about its end
2# point
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 # move to a position in the active block
16 ab.move_ad(-50, 0)
17
18 # create a line
19 line1 = ab.line_ad( 50, 0 )
20
21 # check the line was created
22 if not line1.isNone():
23
24 # create some local variables for the Angle, Position, Retain and NumCopies
25 # options
26 position = line1.end
27 retain = 0
28 angle = 45
29 numCopies = 1
30
31 # select only the line created earlier
32 ab.select_none()
33 line1.selected = 1
34
35 # rotate the line 32 times
36 for i in range(1, 32 + 1):
37 ab.rotate(angle, position, retain, numCopies)