' ' SetHoleToZrapid.bas - Set all holes to retract to the z rapid plane. ' ' Author: Kyle Kershaw ' Organization: Engineering Geometry Systems ' Date: 04/16/2003 Requires Ver 9.3.0.24 or greater ' Copyright (c) 2003, Engineering Geometry Systems ' V1.00 ' ' This macro is intended to be run on a part that has holes that have "combine holes in macro" checked. ' By default, when you check this, all of the holes retract to the plunge clearance (G99). ' This macro will set all hole operations to retract to teh intial plane (G98 - Z rapid) ' ' Creates a toolbar and button when loaded. Button/bar will be removed when marco is unloaded.. ' Option Explicit Public Sub SetHoleRetractToInitialPlane Dim Doc As FMDocument Set Doc = Application.ActiveDocument Dim oper As FMOperation, opers As FMOperations Dim feat_type As Long, oper_type As Long Set opers = Doc.Operations For Each oper In opers oper.GetOperationType( feat_type, oper_type ) If (feat_type = eAT_Hole) Then oper.SetAttribute eAID_DrillRetract,,True,False,False End If Next oper Doc.InvalidateAll 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 "Utilities", "SetHoleRetractToInitialPlane", 13 End Sub ' ' remove button or hide toolbar if add-in deselected ' Private Sub AddIn_OnDisConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) HideDeleteBarButton "Utilities", "SetHoleRetractToInitialPlane" 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