21 | 08 | 2017

Set View

Like in AutoCAD view can be set to viewports or to the modelspace. However you need to set the directions first. Below are sampes of how to set up the code so it corresponds with the same views as the preset views.

Function Setview1(ByVal Sview As String)
 
'****************************************
'*** Code from VisibleVisual.com ********
'****************************************
 
'Preset the view directions
Select Case Sview
 
    Case "top"
        X = 0: Y = 0: Z = 1
    Case "bottom"
        X = 0: Y = 0: Z = -1
    Case "right"
        X = 1: Y = 0: Z = 0
    Case "left"
        X = -1: Y = 0: Z = 0
    Case "front"
        X = 0: Y = -1: Z = 0
    Case "back"
        X = 0: Y = 1: Z = 0
    Case "sw"
        X = -1: Y = -1: Z = 1
    Case "se"
        X = 1: Y = -1: Z = 1
    Case "nw"
        X = 1: Y = 1: Z = 1
    Case "ne"
        X = -1: Y = 1: Z = 1
    Case Else
 
    Exit Function
 
End Select
 
   'Set the prefered view as the active view
 
    Dim Direction(0 To 2) As Double
 
    Direction(0) = X: Direction(1) = Y: Direction(2) = Z
 
    ThisDrawing.ActiveViewport.Direction = Direction
 
End Function
 
 
Sub testview()
 
'Test the Function by calling a preset view
SetView "ne"
 
End Sub

You can add new view directions to get more preset views.


Download AutoCad Views sample Here

 

Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2330587
Latest Articles