Flip selected entities

Flip selected entities
 1# This script flips the selected entities about a horizontal axis,
 2# through the centre of their combined extents
 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    # get the extents of the selected entities
16    selected_extents = ab.get_selected_extents()
17
18    # specify the start and end points for the flip axis, passing through the centre of the selected extents
19    mir_axis_strt = impact.creator.vector(selected_extents.centre.x, selected_extents.centre.y)
20    mir_axis_end = impact.creator.vector(selected_extents.centre.x, selected_extents.centre.y + 1)
21
22    # create some local variables for the entities returned and the retain property
23    entities = None
24    retain = 0
25
26    # perform the mirror operation
27    entities = ab.mirror(mir_axis_strt, mir_axis_end, retain)
28
29    # Wrap variant return items with Impact.py wrapper
30    if entities is not None:
31        entities = [IEntity(item) for item in entities]
32
33    # repaint all entities in this window
34    impact.active_drawing.active_window.repaint()
35
36    # deselect entities
37    ab.select_none()