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

0 Members and 2 Guests are viewing this topic.

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #30 on: November 15, 2007, 11:18:13 AM »

Very Cool Bob, thank you!
I still need to figure out this clipboundary from midpoint problem but I appreciate you modifying the pnt code; it works great and it will be very useful for some things,

I changed the label Boom to NoPoint
On Error Goto NoPoint    LOL

Make sense?  :)

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
Re: Clip Boundaries for a Raster
« Reply #31 on: November 15, 2007, 11:29:13 AM »

I think what you are suggesting is this:

Code: [Select]
NewMidpnt = llpnt(0) + urpnt(0)\2
NewMidpnt = llpnt(1) + urpnt(1)\2
yes and no
you need () around the LL and UR to prevent UR(0)/2  +  LL(0) from happening
Code: [Select]
NewMidpnt = (llpnt(0) + urpnt(0))\2
NewMidpnt = (llpnt(1) + urpnt(1))\2
« Last Edit: November 15, 2007, 11:31:26 AM by CmdrDuh »
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

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
Re: Clip Boundaries for a Raster
« Reply #32 on: November 15, 2007, 11:32:23 AM »
Also look at / vs \
One of those is integer division which will round off your answer to a whole number
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

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #33 on: November 15, 2007, 11:41:44 AM »
OK CM

With your method

You want this:
Code: [Select]
mdpnt(0) = (llpnt(0) + urpnt(0)) / 2
mdpnt(1) = (llpnt(1) + urpnt(1)) / 2
To get your actual value

It looks like the \ operator will round to a whole number

Mark


Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #34 on: November 15, 2007, 11:42:55 AM »
Sorry, just went to the last post, missed a few, but was under the impression you had that taken care of.

Code: [Select]
Dim llpnt As Variant  'lower left point
Dim urpnt As Variant  'upper right point
Dim mdpnt(0 To 1) As Double
Dim clipPoints(0 To 9) As Double

     
With ThisDrawing.Utility
 llpnt = .GetPoint(, vbCrLf & "Select Lower Left : ")
 urpnt = .GetPoint(, vbCrLf & "Select Upper Right: ")
End With

 mdpnt(0) = (urpnt(0) + llpnt(0)) / 2 'Midpoint (X) = (The point in the far left direction) - (The point in the far right direction) / 2
 mdpnt(1) = llpnt(1) + llpnt(1)) / 2 'Midpoint (Y) = (The point in the far top direction) - (The point in the far bottom direction) / 2

[b]'Here is where I need help:[/b]
'Clip boundary = 2.5' from mdpnt to edges. 5' boundary
  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

'Bob Note
'It looks from what you had there, that you still don't understand what you're after
'it looks like you are giving directions for the shape relative to the last point
'That's not what you need to do here.  What you need are the absolute ordinates for each one
'Don't think of it as drawing lines, think of it as plotting points on a graph that
'the command will connect like a dot to dot.  All you are supplying are the dots.

'Clip the image
RastImg.ClipBoundary clipPoints
   
'Enable the display of the clip
RastImg.ClippingEnabled = True
 
 
ThisDrawing.Regen acActiveViewport

[edit]Duh's got the right of it \ gives you an integer / gives you a floating point.
« Last Edit: November 15, 2007, 11:44:04 AM by Bob Wahr »

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #35 on: November 15, 2007, 12:06:46 PM »

BOB!

You are the man!

Oh I see!  :-o
I read your note, thank you for that too! In this case, you are defining (as you said "like plotting points on a graph") "all" points from the midpoint and building the boundary around the midpoint.
As you said, I am treating it like I am drawing a series of lines to build my boundary.
Whereas the way (proper way) you are doing it is giving the absolute coords from the midpoint and acad is connecting the dots to make the boundary (rectangle)
Very cool indeed!

Thank you again   :-)

Mark

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #36 on: November 15, 2007, 01:15:41 PM »
Glad you're getting it.

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #37 on: November 15, 2007, 01:36:45 PM »

Yes sir!

Thank you and thank you for the points code as well.
I like the way you handled that, looping through and incrementing the pnt variable by 1 each time.

Mark

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #38 on: November 15, 2007, 02:08:53 PM »
Thanks

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #39 on: November 15, 2007, 02:21:50 PM »

No thank you :)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
Re: Clip Boundaries for a Raster
« Reply #40 on: November 15, 2007, 02:23:34 PM »
You know what would be cool would be to make a function that had 3 arguments, 2 pts and 1 size.  You could pick your points, pass those to the function, and ask user how big the clipping should be, and have the function return the array of points back to your main function
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

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #41 on: November 15, 2007, 02:24:42 PM »
Conceptually I had the right idea; that was to use the midpoint to build the boundary but getting there was a B***H  LOL

Thanks guys!

Mark

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #42 on: November 15, 2007, 02:28:09 PM »

CM
That sounds cool but I think we hit that already, only not with a function

Wouldn't this method kind of do that?

User just picks points on the raster and it is clipped accordingly

Code: [Select]
'Clip boundary = picked points (llpnt and 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)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4043
Re: Clip Boundaries for a Raster
« Reply #43 on: November 15, 2007, 02:29:33 PM »
Yes, but we have hard coded the 5x5. what if we want to change the size of the clipping on the fly
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

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #44 on: November 15, 2007, 02:51:23 PM »

Your idea is really cool but this code here
Code: [Select]
'Clip boundary = picked points (llpnt and 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)
Is not hardcoding a 5 x5; it is creating the clip boundary based off of the lower left and upper right picked points.

So, bascially your function only needs to fill in the values for the variables llpnt and urpnt; I think

So; if the user inputs 10 x 10; then we need to retrieve that data and do the math on llpnt and urpnt