' ' RemoveAllCribSlotOverrides.bas - Remove all tool slot assignments that have been set as a property of the tool. ' ' Author: Kyle Kershaw ' Organization: Engineering Geometry Systems ' Date: 8/26/2004 ' Copyright (c) 2004, Engineering Geometry Systems ' ' General Description ' ' This macro will reset all tool number overrides to zero for all milling tools in the ' active tool crib. ' ' Create a toolbar and button when activated, removes it when deactivated. ' Option Explicit Sub RemoveAllCribSlotOverrides Begin Dialog UserDialog 340,140,"Remove Tool Overrides" ' %GRID:10,7,1,1 Text 40,21,290,35,"WARNING: This macro will remove all tool slot assignments that have set as a tool property for the current tool crib",.Text1 Text 40,63,290,28,"This includes tool that have been ""Set in Crib"" from the Tool Mapping dialog",.Text2 OKButton 40,105,90,21 CancelButton 180,105,130,21 End Dialog Dim dlg As UserDialog, result As Integer result = Dialog( dlg ) If (result <> -1) Then ' OK button was pressed Exit Sub End If Dim doc As FMDocument Set doc = Application.ActiveDocument Dim crib As FMToolCrib Set crib = doc.ActiveToolCrib Dim tool As FMTool For Each tool In crib.BoringBars If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.ChamferMills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.CounterBores If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.CounterSinks If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.EndMills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.FaceMills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.PlungeRoughers If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.Reamers If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.RoundingMills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.SideMills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.SpotDrills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.Taps If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.ThreadMills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next For Each tool In crib.TwistDrills If (tool.DefToolSlot <> 0) Then tool.DefToolSlot = 0 Next crib.SaveCrib End Sub Private Sub AddIn_OnConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) ' Bar name Button name Button face ID MakeButtonAndBar "Utility", "RemoveAllCribSlotOverrides", 37 End Sub Private Sub AddIn_OnDisConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) HideDeleteBarButton "Utility", "RemoveAllCribSlotOverrides" 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