Author Topic: Clip Boundaries for a Raster  (Read 38627 times)

0 Members and 2 Guests are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #60 on: November 15, 2007, 03:38:49 PM »
A couple of other thoughts to throw out to you.  with the two point selection method, you could just check the distance, round to the nearest whole number, and clip.  For a midpoint centered clip, you can just get them to pick a center point and distance instead of two points.
This actually is less coding, and allows the user to "center" the clipping box based on a selected point.  Much easier and cleaner if you ask me
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #61 on: November 15, 2007, 03:40:10 PM »
Bob is on the right track of what I was thinking.  Bob, how do you do the default thing???  In LISP I know you use <> to define it, but I never learned how in VBA
You use error handling with VBA I throw the <crap> into my prompt so it looks familiar to Johnny Caduserguy but it's handle with the error trapping.
So you trap NULL?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #62 on: November 15, 2007, 03:41:06 PM »
do you use a form of initget? and set bits to allow null entry, and then trap for the null?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #63 on: November 15, 2007, 03:51:10 PM »
Quote
This actually is less coding, and allows the user to "center" the clipping box based on a selected point.  Much easier and cleaner if you ask me

It is actually a very clever idea but it still all boils down to "what" is the need

In my application; it needs to be fitted into a 5 x 5 box on a title block; so yes, they could have said I prefer to have this area centered but that is ok; then can still pick a very small or specific area on the raster and the 5 x 5 will get made with that area is basically centered.
I think this offers a lot of flexibility as they have the window option.

I am curious to try that dynamic boundary code though

Mark


David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #64 on: November 15, 2007, 04:08:15 PM »
ill write something up for you
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #65 on: November 15, 2007, 04:09:51 PM »
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

Code: [Select]
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


David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #66 on: November 15, 2007, 04:17:28 PM »
guess you beat me to it, Ill just chec thru yours
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #67 on: November 15, 2007, 04:19:50 PM »
the only thing I see, which has no effect on the running of the code b/c order of operation is correct is
Code: [Select]
clipPoints(0) = mdpnt(0) - Bndsize / 2While it is correct, I would personally use () to make it clearer to someone reading it that Bndsize/2 comes before MP-
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #68 on: November 15, 2007, 04:20:15 PM »
clipPoints(0) = mdpnt(0) - (Bndsize / 2)
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #69 on: November 15, 2007, 04:21:54 PM »
The only thing I noticed is that it did not regenerate on bigger sizes; not sure why.
what if you place a breakpoint, does it stop there?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #70 on: November 15, 2007, 04:28:40 PM »
You might try thowing a RastImg.Update in there, not sure if it will help.

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #71 on: November 15, 2007, 04:29:16 PM »
Haven't tried that but I certainly can

Here you go sir

Code: [Select]
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)

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #72 on: November 15, 2007, 05:01:14 PM »


Bob

RastImg.Update

Did not help


Mark

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #73 on: November 15, 2007, 05:03:15 PM »
You're gonna make me open autocad, aren't you?

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #74 on: November 15, 2007, 06:29:21 PM »

LOL

No, I'm sure not

I think we have worked you enough today  LOL

Tomorrow is a new day!  :-)

Mark