' ' HorizontalViews.bas - create custom view for horizontal spindle machines. ' ' Author: Kyle Kershaw ' Organization: Engineering Geometry Systems ' Date: 10/20/2004 ' Copyright (c) 2004, 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 is invoked by a macro toolbar button ' Option Explicit Public Sub LeftView SetView -1,0,0,0,0,1 End Sub Public Sub LeftIsometricView SetView -.25,.125,.5,1,-.1,0 End Sub Public Sub TopView SetView 0,0,1,1,0,0 End Sub Public Sub FrontView SetView 0,-1,0,1,0,0 End Sub Public Sub RightView SetView 1,0,0,0,0,-1 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 MFGDocument 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 "Horizontal_Views" MakeButtonOnBar "Horizontal_Views", "LeftView", 11 MakeButtonOnBar "Horizontal_Views", "LeftIsometricView", 27 MakeButtonOnBar "Horizontal_Views", "TopView", 14 MakeButtonOnBar "Horizontal_Views", "FrontView", 13 MakeButtonOnBar "Horizontal_Views", "RightView", 12 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 = "Horizontal_Views" Set bars = Application.CommandBars Set bar = bars(bar_name) If Not bar Is Nothing Then bar.Visible=False End If End Sub