' ' customviews.bas - create custom views ' ' Author: Kyle Kershaw ' Organization: Engineering Geometry Systems ' Date: 1/8/03 ' Copyright (c) 2003, Engineering Geometry Systems ' ' General Description ' ' This macro sets the view according to the view vector parameters passed from each Sub ' ' The view orientation can be changed by modifying the parameters following each SetView statement. ' ' Each sub in invoked by a macro toolbar button ' Option Explicit Public Sub LeftIsometricView SetView -1,-1,1,1,-1,0 End Sub Public Sub RightIsometricView SetView 1,-1,1,1,1,0 End Sub Public Sub LeftDimetricView SetView -1,-1,.5,1,-1,0 End Sub Public Sub RightDimetricView SetView 1,-1,.5,1,1,0 End Sub Public Sub OddBallView SetView .2884,-.2127,.9336,.7673,.6346,.35 End Sub ' ' sets viewpoint with parameters from calling sub ' Private Sub SetView(ByVal Zx As Double, ByVal Zy As Double, ByVal Zz As Double, _ ByVal Xx As Double, ByVal Xy As Double, ByVal Xz As Double) Dim Doc As FMDocument Set Doc = ActiveDocument Doc.SetViewVector(Zx,Zy,Zz,Xx,Xy,Xz) End Sub ' ' Add a toolbar and buttons upon loading of this addin into FeatureCAM. ' Private Sub AddIn_OnConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) MakeToolBar "ViewsTest" MakeButtonOnBar "ViewsTest", "LeftIsometricView", 13 MakeButtonOnBar "ViewsTest", "LeftDimetricView", 11 MakeButtonOnBar "ViewsTest", "RightDimetricView", 12 MakeButtonOnBar "ViewsTest", "RightIsometricView", 14 MakeButtonOnBar "ViewsTest", "OddBallView", 27 End Sub ' ' Create toolbar ' Private Sub MakeToolBar(ByVal bar_name As String) Dim bars As FMCmdBars, bar As FMCmdBar Set bars = Application.CommandBars Set bar = bars(bar_name) If bar Is Nothing Then Set bar = bars.Add(bar_name) Else bar.Visible = True End If End Sub ' ' create button on toolbar ' Private Sub MakeButtonOnBar(ByVal bar_name As String, ByVal button_name As String, _ ByVal button_id As Integer) Dim bars As FMCmdBars, bar As FMCmdBar, ctrl As FMCmdBarBtn Set bars = Application.CommandBars Set bar = bars(bar_name) Set ctrl = bar.Controls(button_name) If ctrl Is Nothing Then Set ctrl = bar.Controls.Add( ,,button_name) ctrl.FaceId = button_id bar.Visible = True End If End Sub ' ' Hide toolbar if add-in deselected ' Private Sub AddIn_OnDisConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) Dim bars As FMCmdBars, bar As FMCmdBar, bar_name As String bar_name = "ViewsTest" Set bars = Application.CommandBars Set bar = bars(bar_name) If Not bar Is Nothing Then bar.Visible=False End If End Sub