Rotate selected entities (Python)¶
Rotate selected entities (Python)¶
1# This script rotates any selected entities by 90 degress
2# (270 degress Counter-Clockwise) around their centre position
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 # create a local variable for the active block
12 ab = impact.active_drawing.active_layer.active_block
13
14 # get the selected entity extents
15 rect = ab.get_selected_extents()
16
17 # create some local variables for the Angle, Position, Retain
18 # and NumCopies options
19 position = rect.centre
20 retain = 0
21 angle = 270
22 numCopies = 1
23
24 # rotate the selected entities
25 ab.rotate(angle, position, retain, numCopies)
26
27 # repaint all entities in this window
28 impact.active_drawing.active_window.repaint()
29
30 # deselect entities
31 ab.select_none()