Consulting

Results 1 to 13 of 13

Thread: VBA code to change view from iso to top?

  1. #1
    VBAX Regular
    Joined
    Jul 2007
    Posts
    34
    Location

    VBA code to change view from iso to top?

    Hello Everyone!

    Does anyone know the VBA line of code that will change an isometric view in model space to a top view??

    I have searched and have come up empty?

    Thanks,
    Rob

  2. #2
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Hi Rob
    Try to use SenCommand method
    I think easiest one

    [vba]
    Sub top()
    ThisDrawing.SendCommand "-VIEW _TOP " '<--blank space after TOP
    End Sub
    [/vba]

    ~'J'~

  3. #3
    VBAX Regular
    Joined
    Jul 2007
    Posts
    34
    Location
    Hi Fatty:

    Its not working, though it runs in the program without any VB errors.

    any other ideas?

    Thanks for the help!

    Rob

  4. #4
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Rob,
    it works for me in 2005.
    did you copy it exactly and paste it into a module?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Quote Originally Posted by RMS
    Hi Fatty:

    Its not working, though it runs in the program without any VB errors.

    any other ideas?

    Thanks for the help!

    Rob
    Hay, Rob
    Try this instead
    Btw, I don't like SendCommand too because
    this work differently in the different version
    Here is adopted example from help

    [vba]
    Sub Ch_ViewDir()
    '
    'based on Direction Property Example in the Help file
    '
    Dim vecDir(2) As Double
    ' Define the valid keywords
    Dim keywordList As String
    keywordList = "Top Bottom Right Left Front BAck"
    ' Call InitializeUserInput to setup the keywords
    ThisDrawing.Utility.InitializeUserInput 1, keywordList
    ' ' Prompt the user to input any of the keywords. Return "Top" "Bottom" "Right" "Left" "Front" or "Back" in
    ' the returnString variable depending on whether the user input "T" or "t", "B" or "B", "BA" or "ba", etc. .
    Dim response As String
    response = ThisDrawing.Utility.GetKeyword("Choose a view direction (Top)(Bottom)(Right)(Left)(Front)(BAck): ")
    'MsgBox response 'debug only
    '
    ' Define the direction vector , depending on the returned view name.
    Select Case response
    Case "Top"
    vecDir(0) = 0: vecDir(1) = 0: vecDir(2) = 1
    Case "Bottom"
    vecDir(0) = 0: vecDir(1) = 0: vecDir(2) = -1
    Case "Right"
    vecDir(0) = 1: vecDir(1) = 0: vecDir(2) = 0
    Case "Left"
    vecDir(0) = -1: vecDir(1) = 0: vecDir(2) = 0
    Case "Front"
    vecDir(0) = 0: vecDir(1) = -1: vecDir(2) = 0
    Case "BAck"
    vecDir(0) = 0: vecDir(1) = 1: vecDir(2) = 0
    End Select
    ' Change the direction of the viewport so that you can
    ' view the change made. Once you change
    ' the direction, you must reset the active viewport.
    With ThisDrawing
    .ActiveViewport.Direction = vecDir
    .ActiveViewport = .ActiveViewport
    End With
    ZoomExtents
    End Sub
    [/vba]

    ~'J'~

  6. #6
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Quote Originally Posted by lucas
    Hi Rob,
    it works for me in 2005.
    did you copy it exactly and paste it into a module?
    Hay, Lucas
    Glad to hear again
    Thanks for the testing
    Regards,

    Oleg

    ~'J'~

  7. #7
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Oleg,
    Same here, glad to see you still visiting the forum.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    Quote Originally Posted by lucas
    Hi Rob,
    it works for me in 2005.
    did you copy it exactly and paste it into a module?
    Hey Lucas , yeah I did cut and paste not sure why it did not work.

    How is everything in the guitar world!

    Quote Originally Posted by Fatty
    Hay, Rob
    Try this instead
    Btw, I don't like SendCommand too because
    this work differently in the different version
    Here is adopted example from help

    ~'J'~
    Wow, Fatty, thats a lot of code! When I get back to work on Tuesday I will give that a try. I was not sure what to search for in the AutoCAD VBA
    object browser.

    By the way, I have been super bussy learning the C++ and its going really
    good so far, but lots to learn!

    Thanks for the help guys!!
    Rob

  9. #9
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Hi Rob
    Unfortunatelly I am not so smart and not so young
    to learn C++
    I am enviuous on you by this reason )
    Anyway I have to try to learn VB.NET instead, it's
    easier a bit for me
    Have you succes on this way
    Cheers

    ~'J'~

  10. #10
    Quote Originally Posted by Fatty
    Hi Rob
    Unfortunatelly I am not so smart and not so young
    to learn C++
    I am enviuous on you by this reason )
    Anyway I have to try to learn VB.NET instead, it's
    easier a bit for me
    Have you succes on this way
    Cheers

    ~'J'~
    Thanks Fatty, and good luck with the VB.NET !

    I read an artical the other night about the .NET stuff, one thing that stuck out was it has the ability to combine or merge languges, so you can write in it with your favorite programing language, not sure if I got this correct but here is the artical:

    "....NET should help with that; it provides an environment where multiple languages can seamlessly co-exist (even on the class inheritance chain, or during debugging). So there should be less pressure to develop products monolithically in a single language; you'll use whatever language suits the task/suits you." -see #19 at bottom of this interview:

    http://www.cpp-home.com/index/tiki-r...hp?articleId=3

    its an old artical from 2002

    Rob

  11. #11
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Rob,
    Alice N Chains unplugged @ Cains Ball Room in Tulsa 2 weeks from now....we have our tickets.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  12. #12
    Quote Originally Posted by lucas
    Hi Rob,
    Alice N Chains unplugged @ Cains Ball Room in Tulsa 2 weeks from now....we have our tickets.
    Wow, that band is incredable in two ways, there unpluged stuff is like no other rock band and when it comes to recording there hard rock stuff the guitars parts really just seem to stand out and jump out at ya... I don't know how to explain it I guess its just tallent all arround!

  13. #13
    VBAX Regular fixo's Avatar
    Joined
    Jul 2006
    Location
    Sankt-Petersburg
    Posts
    99
    Location
    Quote Originally Posted by Zrob
    Thanks Fatty, and good luck with the VB.NET !

    I read an artical the other night about the .NET stuff, one thing that stuck out was it has the ability to combine or merge languges, so you can write in it with your favorite programing language, not sure if I got this correct but here is the artical:

    "....NET should help with that; it provides an environment where multiple languages can seamlessly co-exist (even on the class inheritance chain, or during debugging). So there should be less pressure to develop products monolithically in a single language; you'll use whatever language suits the task/suits you." -see #19 at bottom of this interview:

    http://www.cpp-home.com/index/tiki-r...hp?articleId=3

    its an old artical from 2002

    Rob
    Thanks Rob,

    Interesting info btw

    Good luck

    ~'J'~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •