Get the current view

Discussion in 'AutoCAD' started by Andrew Elmore, Jun 27, 2003.

  1. Can some one tell me how to get the current view (i.e.
    Top,Bottom,Left,Right,Front,Back)

    Andy
     
    Andrew Elmore, Jun 27, 2003
    #1
  2. Andrew Elmore

    Kevin Terry Guest

    do you mean in model space, what direction you're looking from? or are you
    talking about some paperspace viewports? is it vanilla autocad you're
    working in, or one of the vertical products?

    Kevin
     
    Kevin Terry, Jun 27, 2003
    #2
  3. When in modelspace and/or paperspace. if I change the current view to say
    front then have have a message box promt the current view that I'm looking
    from. If I can get that then I can figure the rest of the code out. (I'm
    going to have layers frozen and unfrozen depending on the current view)

    I'm useing ADT 2004. for this program.

    Thanks,
    Andy
     
    Andrew Elmore, Jun 27, 2003
    #3
  4. Andrew Elmore

    Kevin Terry Guest

    Don't know if this will be of any help to you, but check out the sample
    installed on your computer called example_events.DVB (C:\Program
    Files\MDT6\Sample\VBA\example_events.DVB on mine).

    Kevin
     
    Kevin Terry, Jun 30, 2003
    #4
  5. Andrew Elmore

    Kevin Terry Guest

    do a search on your hard drive or installation cd - it's provided with your
    standard licensed copy of whatever autocad product you have.

    Kevin
     
    Kevin Terry, Jun 30, 2003
    #5
  6. I searched the hard drive ADT,ACAD and no file close to example_Events

    Andy
     
    Andrew Elmore, Jun 30, 2003
    #6
  7. Can get the VBA to get the command -View; but I can't get what the user
    selected top,bot,sw, ect...

    anybody know how to get this.

    Andy
     
    Andrew Elmore, Jul 2, 2003
    #7
  8. You could do something brute-force like the following. Set the views
    yourself and check the variable manually to populate your If...Then (If you
    want the function to work when someone chooses their view relative to the
    UCS, you'd need to add another flag to the sub). The 'eq' function is just
    to get past the computer's exactness. This is a non-working example.
    Good luck,
    James

    Function WhichViewActive() as string
    dim varViewDir as variant
    varViewDir = getVariable("VIEWDIR")
    Dim varVD_WCS As Variant 'view direction vector, translated from UCS to
    WCS
    varVD_WCS = ThisDrawing.Utility.TranslateCoordinates(varVD, acUCS,
    acWorld, True)

    vX = varVD_WCS (0)
    vY = varVD_WCS (1)
    vZ = varVD_WCS (2)
    if EQ(vX,0,0.01) and EQ(vY,0,0.01) and EQ(vZ,-1,0.01) then
    WhichViewActive = "TOP"
    elseif EQ(vX,0,0.01) and ...
    WhichViewActive = ...
    else
    WhichViewActive = "UNKNOWN"
    endif
    End Function
    Public Function eq(val1 As Double, val2 As Double, fuzz As Double) As
    Boolean
    'function courtesy of www.acadx.com
    eq = Abs(val1 - val2) <= fuzz
    End Function
     
    James Belshan, Jul 2, 2003
    #8
  9. Andrew Elmore

    Andy Elmore Guest

    Thanks James
     
    Andy Elmore, Jul 5, 2003
    #9
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.