OK Guys
Here is the total accumulation of what we had done; hopefully others can benefit from it.
Bob, your last method is the last one in the code; the rest are commented out
It is really cool!
The user can type in the size and it is created.
The only thing I noticed is that it did not regenerate on bigger sizes; not sure why.
Mark
Sub InstRast()
Dim RastImg As AcadRasterImage
Dim Imgpth As String
Dim Imgname As String
Dim InsertPnt(0 To 2) As Double, scalefactor As Double, RotAngle As Double
Imgpth = "Path"
Imgname = "filename"
InsertPnt(0) = 0#: InsertPnt(1) = 0#: InsertPnt(2) = 0#
scalefactor = 1
RotAngle = 0
On Error GoTo Errorhandler
Set RastImg = ThisDrawing.PaperSpace.AddRaster(Imgpth & Imgname, InsertPnt, scalefactor, RotAngle)
RastImg.Name = Imgname
RastImg.Name = Left(Imgname, Len(Imgname) - 4)
RastImg.scalefactor = 12
'Move Points
Dim Point1(0 To 2) As Double
Dim Point2(0 To 2) As Double
Point1(0) = 8: Point1(1) = 0: Point1(2) = 0
Point2(0) = 0: Point2(1) = 0: Point2(2) = 0
'Move Raster
RastImg.Move Point1, Point2
Errorhandler:
If Err.Description = "File access error" Then
If MsgBox("Can not find image file") Then
Exit Sub
End If
End If
Dim llpnt As Variant 'lower left point
Dim urpnt As Variant 'upper right point
Dim mdpnt(0 To 2) As Double
Dim clipPoints(0 To 9) As Double
With ThisDrawing.Utility
llpnt = .GetPoint(, vbCrLf & "Select Lower Left Point: ")
urpnt = .GetPoint(, vbCrLf & "Select Upper Right Point: ")
End With
mdpnt(0) = (llpnt(0) + urpnt(0)) / 2 'Midpoint (X) = (The far left picked point + the far right picked point) / 2
mdpnt(1) = (llpnt(1) + urpnt(1)) / 2 'Midpoint (Y) = (The far bottom picked point + the far top picked point) / 2
mdpnt(2) = 0
'FINITE
'Create a 5 x 5 clip boundary
' clipPoints(0) = 0: clipPoints(1) = 0
' clipPoints(2) = 0: clipPoints(3) = 5
' clipPoints(4) = 5: clipPoints(5) = 5
' clipPoints(6) = 5: clipPoints(7) = 0
' clipPoints(8) = 0: clipPoints(9) = 0
'Clip boundary = 2.5 from the mdpnt of the raster's picked points to the boundary coords.
' clipPoints(0) = mdpnt(0) - 2.5: clipPoints(1) = mdpnt(1) - 2.5
' clipPoints(2) = mdpnt(0) - 2.5: clipPoints(3) = mdpnt(1) + 2.5
' clipPoints(4) = mdpnt(0) + 2.5: clipPoints(5) = mdpnt(1) + 2.5
' clipPoints(6) = mdpnt(0) + 2.5: clipPoints(7) = mdpnt(1) - 2.5
' clipPoints(8) = mdpnt(0) - 2.5: clipPoints(9) = mdpnt(1) + -2.5
'DYNAMIC
'Clip boundary = picked points (llpnt + urpnt)
' clipPoints(0) = llpnt(0): clipPoints(1) = llpnt(1)
' clipPoints(2) = llpnt(0): clipPoints(3) = urpnt(1)
' clipPoints(4) = urpnt(0): clipPoints(5) = urpnt(1)
' clipPoints(6) = urpnt(0): clipPoints(7) = llpnt(1)
' clipPoints(8) = llpnt(0): clipPoints(9) = llpnt(1)
'Clip boundary = user defined size
Dim Bndsize As Integer
Bndsize = ThisDrawing.Utility.GetReal("What size boundary would you like?: ")
clipPoints(0) = mdpnt(0) - Bndsize / 2: clipPoints(1) = mdpnt(1) - Bndsize / 2
clipPoints(2) = mdpnt(0) - Bndsize / 2: clipPoints(3) = mdpnt(1) + Bndsize / 2
clipPoints(4) = mdpnt(0) + Bndsize / 2: clipPoints(5) = mdpnt(1) + Bndsize / 2
clipPoints(6) = mdpnt(0) + Bndsize / 2: clipPoints(7) = mdpnt(1) - Bndsize / 2
clipPoints(8) = mdpnt(0) - Bndsize / 2: clipPoints(9) = mdpnt(1) + -Bndsize / 2
'Clip the image
RastImg.ClipBoundary clipPoints
'Enable the display of the clip
RastImg.ClippingEnabled = True
ThisDrawing.Regen acActiveViewport
End Sub