' CopyMyConfiguration.bas ' ' Author: Kyle Kershaw ' Organization: Engineering Geometry Systems ' Date: 2/2/2004 ' Copyright (c) 2004, Engineering Geometry Systems ' ' General Description ' ' This macro copies the "My Configuration" configuration to the current document. ' Option Explicit Sub CopyMyConfiguration Dim doc As FMDocument Set doc = Application.ActiveDocument Dim confs As FMConfigurations Set confs = Application.Configurations Dim conf As FMConfiguration For Each conf In confs If (conf = doc) Then conf.CopyConfiguration "My Configuration" Exit For End If Next conf End Sub ' Add a toolbar and buttons upon loading of this addin into FeatureCAM. ' Private Sub AddIn_OnConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) ' Bar name Button name Button face ID MakeButtonAndBar "CAD", "CopyMyConfiguration", 41 End Sub ' ' remove button or hide toolbar if add-in deselected ' Private Sub AddIn_OnDisConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) HideDeleteBarButton "CAD", "CopyMyConfiguration" End Sub Private Sub MakeButtonAndBar(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) If bar Is Nothing Then Set bar = bars.Add(bar_name) Else bar.Visible = True End If 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 Private Sub HideDeleteBarButton(ByVal bar_name As String, ByVal button_name As String) Dim bars As FMCmdBars, bar As FMCmdBar, ctrl As FMCmdBarCtrl Set bars = Application.CommandBars Set bar = bars(bar_name) If Not bar Is Nothing Then Set ctrl = bar.Controls(button_name) If Not ctrl Is Nothing Then If bar.Controls.Count > 1 Then ctrl.Delete Else bar.Visible=False End If End If End If End Sub