Thanks sofar. With your help I wrote this code. But there's something wrong and I can't find out what...
Public Sub HorizontalFlip()
'Corrected after Bryco's hint about variable declaration syntax (ver. below).
'Now it works!
Dim Thingy As AcadEntity
Dim LayerName As String
Dim MostLeftX as Double, MostRightX As Double 'thanks Bryco!
Dim BBoxMin, BBoxMax 'variants, will later be specified by GetBoundingBox
Dim FlippointA(0 To 2) as Double, FlippointB(0 To 2) As Double 'thanks Bryco!
MostLeftX = 2147483647: MostRightX = -2147483647
LayerName = "0" 'can be any valid layername
For Each Thingy In ThisDrawing.ModelSpace
If Thingy.Layer = LayerName Then
Thingy.GetBoundingBox BBoxMin, BBoxMax
If BBoxMin(0) < MostLeftX Then MostLeftX = BBoxMin(0)
If BBoxMax(0) > MostRightX Then MostRightX = BBoxMax(0)
End If
Next
'I now have MostLeftX and MostRightX for all geometry on layer.
'next, I define the mirror line, halfway between MostLeftX and MostRightX
FlippointA(0) = (MostLeftX + MostRightX) / 2: FlippointB(0) = FlippointA(0)
FlippointA(1) = 0: FlippointB(1) = 1
FlippointA(2) = 0: FlippointB(2) = 0 'endpoints of the vertical mirror line
'finally, I want to horizontally flip all entities on the layer
For Each Thingy In ThisDrawing.ModelSpace
If Thingy.Layer = LayerName Then
Thingy.Mirror FlippointA, FlippointB 'thanks Dnereb!
Thingy.Delete
End If
Next
End Sub
What am I overlooking?