Finding certain corner in Rectangle

Discussion in 'AutoCAD' started by Nathan Guill, May 7, 2004.

  1. Nathan Guill

    Nathan Guill Guest

    I know this is probably simple, but my brain isn't working this morning. I
    need to find the lower left corner of a rectangle. I would like to do this
    without drawing the rectangle (using the getcorner method) if possible.
    Thanks for any help.
     
    Nathan Guill, May 7, 2004
    #1
  2. Nathan Guill

    bcoward Guest

    Nathan,

    YourBrain.BrainEngaged()

    Dim strMyMsg As String
    Dim varStartPt As Variant
    Dim varPickPt As Variant

    With ThisDrawing.Utility
    varStartPt = .GetPoint(, vbCr & "pick first corner")
    varPickPt = .GetCorner(varStartPt, vbLf & "pick next corner")
    End With

    strMyMsg = varPickPt(0) & " : " & varPickPt(1) & " : " & varPickPt(2)

    MsgBox strMyMsg

    Hope this helps,

    Bob Coward
    CADS, Inc

    800-366-0946
     
    bcoward, May 7, 2004
    #2
  3. Nathan Guill

    Nathan Guill Guest

    This wouldn't necessarily give you the lower left corner. If, say, the user
    picked the lower right corner and then the upper left corner, this would
    give you the upper left corner.
     
    Nathan Guill, May 7, 2004
    #3
  4. Do you mean an actual rectangle (an LWPOLYLINE) or just two points?
     
    Frank Oquendo, May 7, 2004
    #4
  5. Nathan Guill

    Nathan Guill Guest

    Well, I would like it to be from just two points. IF I have to create the
    polyline to get the information and then erase the polyline, I'll do it.
     
    Nathan Guill, May 7, 2004
    #5
  6. In general, simply compare the X and Y ordinates of each point. Take the
    lowest value for each and you've got the lower left corner:

    ' Assume we've acquired points P1 and P2

    Dim P3 As Double(2) ' Change to 1 for 2D point

    P3(0) = IIf(P1(0) < P2(0), P1(0), P2(0))
    P3(1) = IIf(P1(1) < P2(1), P1(1), P2(1))
     
    Frank Oquendo, May 7, 2004
    #6
  7. Nathan Guill

    Nathan Guill Guest

    Thank you. I new it was easy, just couldn't think of it.
     
    Nathan Guill, May 7, 2004
    #7
  8. Nathan Guill

    wivory Guest

    Careful here. Depending which two points you are examining this might only work if the rectangle is "flat" on the X-axis. If the rectangle was "tilted" to the right the lowest Y value would come from the bottom-right corner and the lowest X value would come from the bottom-left corner.

    If I'm trying to find the bottom-left vertex of a polyline I iterate the vertices and do the following (psuedo-code):

    [pre]
    If (Y < LowestY) Or (Y = LowestY and X < LowestX) Then ' Make this point the new bottom-left
    [/pre]

    Regards

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, May 10, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.