' User Defined Feature (UDF) and User Defined Operation (UDO) for: ' Finding the center of the part in X and Y using probing. ' Uses Cincinnatti CLS sub-routines specific to Cardinal Manufacturing ' ' You need a tool called "SPINDLE PROBE" in the Endmill tool group of your ' current crib. ' ' Option Explicit Dim udfr_xycenter As FMUserFeatureRegister Dim udfo_xycenter As FMUserOperationRegister Dim xy_xedge As Long, xy_yedge As Long, xy_surf_loc As Long, xy_zdepth As Long, xy_zclear As Long Dim udfr_ycenter_xedge As FMUserFeatureRegister Dim udfo_ycenter_xedge As FMUserOperationRegister Dim ycxe_xedge As Long, ycxe_yedge As Long, ycxe_surf_loc As Long, ycxe_zdepth As Long, ycxe_zclear As Long, ycxe_zfind As Long, ycxe_edge As Long Dim udfr_xcenter_yedge As FMUserFeatureRegister Dim udfo_xcenter_yedge As FMUserOperationRegister Dim xcye_xedge As Long, xcye_yedge As Long, xcye_surf_loc As Long, xcye_zdepth As Long, xcye_zclear As Long, xcye_zfind As Long, xcye_edge As Long Dim udfr_zsurface As FMUserFeatureRegister Dim udfo_zsurface As FMUserOperationRegister Dim zs_surf_loc As Long, zs_zclear As Long, zs_zfind As Long Dim udfr_yedge As FMUserFeatureRegister Dim udfo_yedge As FMUserOperationRegister Dim ye_xedge As Long, ye_yedge As Long, ye_zdepth As Long, ye_zclear As Long, ye_zfind As Long, ye_edge As Long Dim udfr_xedge As FMUserFeatureRegister Dim udfo_xedge As FMUserOperationRegister Dim xe_xedge As Long, xe_yedge As Long, xe_zdepth As Long, xe_zclear As Long, xe_zfind As Long, xe_edge As Long Dim udfr_corner As FMUserFeatureRegister Dim udfo_corner As FMUserOperationRegister Dim c_type As Long, c_corner As Long, c_corner_loc As Long, c_surf_loc As Long, c_zdepth As Long, c_zclear As Long, c_zfind As Long Dim udfr_boss As FMUserFeatureRegister Dim udfo_boss As FMUserOperationRegister Dim b_surf_loc As Long, b_zdepth As Long, b_zclear As Long, b_zfind As Long, b_dia As Long Dim udfr_hole As FMUserFeatureRegister Dim udfo_hole As FMUserOperationRegister Dim h_surf_loc As Long, h_zdepth As Long, h_zclear As Long, h_zfind As Long, h_dia As Long Dim udfr_L_zsurface As FMUserFeatureRegister Dim udfo_L_zsurface As FMUserOperationRegister Dim Lzs_setup_origin As Long, Lzs_stkover As Long, Lzs_type As Long, Lzs_xedge As Long Dim udfr_L_zcenter_xsurface As FMUserFeatureRegister Dim udfo_L_zcenter_xsurface As FMUserOperationRegister Dim Lzcxs_xedge As Long, Lzcxs_xedge2 As Long, Lzcxs_stkover As Long, Lzcxs_finishl As Long Dim unloading As Boolean ' this event handler registers the UDF and UDOs with featurecam. ' registration is required in order for the UDF radio button to appear in the new feature dialog. ' registraion also defines the parameters of the UDF and UDOs. ' ' this event handler is executed whenever the addin is loaded. ' this occurs when the macro is checked as an Add-in in the Add-in dialog or ' when featurecam starts provided it was checked as an add-in the last time ' you were running featurecam. Private Sub AddIn_OnConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) Set udfr_xycenter = Application.RegisterUserFeature( "Probing:Center XY", eST_Milling, "probing_xycenter", eUDF_PickLocation) xy_xedge = udfr_xycenter.AddDataDefinition ( "X loc. for Y edge pickup", eUDT_PickX, 0, 0) xy_yedge = udfr_xycenter.AddDataDefinition ( "Y loc. for X edge pickup", eUDT_PickY, 0, 0) xy_surf_loc = udfr_xycenter.AddDataDefinition ( "XYZ loc. for surface pickup", eUDT_PickPoint, "0,0,0", "0,0,0") udfr_xycenter.AddDataDefinition ( "",eUDT_None,"","") xy_zdepth = udfr_xycenter.AddDataDefinition ( "Probe Z depth for edge pickup", eUDT_Double, -.2, 6) xy_zclear = udfr_xycenter.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) udfr_xycenter.AddDataDefinition ( "",eUDT_None,"","") udfr_xycenter.AddDataDefinition ( "",eUDT_None,"","") udfr_xycenter.AddDataDefinition ( "",eUDT_None,"","") udfr_xycenter.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_xycenter = Application.RegisterUserOperation( "Probe Center XY", "Probe Center XY", eTG_EndMill, eST_Milling) udfo_xycenter.AddAttributeDefinition2 eAID_Priority Dim ycenter_xedge_drop(1) As String ycenter_xedge_drop(0) = "Left" ycenter_xedge_drop(1) = "Right" Set udfr_ycenter_xedge = Application.RegisterUserFeature( "Probing:YCenter,XEdge", eST_Milling, "probing_ycenter_xedge", eUDF_PickLocation) ycxe_xedge = udfr_ycenter_xedge.AddDataDefinition ( "X loc. for Y center pickup", eUDT_PickX, 0, 0) ycxe_yedge = udfr_ycenter_xedge.AddDataDefinition ( "Y loc. for X edge pickup", eUDT_PickY, 0, 0) ycxe_edge = udfr_ycenter_xedge.AddDataDefinition ( "Type", eUDT_DropList, 0, 0, ycenter_xedge_drop) udfr_ycenter_xedge.AddDataDefinition ( "",eUDT_None,"","") ycxe_surf_loc = udfr_ycenter_xedge.AddDataDefinition ( "XYZ loc. for surface pickup", eUDT_PickPoint, "0,0,0", "0,0,0") udfr_ycenter_xedge.AddDataDefinition ( "",eUDT_None,"","") ycxe_zdepth = udfr_ycenter_xedge.AddDataDefinition ( "Probe Z depth for edge pickup", eUDT_Double, -.2, 6) ycxe_zclear = udfr_ycenter_xedge.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) ycxe_zfind = udfr_ycenter_xedge.AddDataDefinition ( "Probe Z edge hit clearance",eUDT_Double, 2.8,75) udfr_ycenter_xedge.AddDataDefinition ( "",eUDT_None,"","") udfr_ycenter_xedge.AddDataDefinition ( "",eUDT_None,"","") udfr_ycenter_xedge.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_ycenter_xedge = Application.RegisterUserOperation( "Probe YCenter,XEdge", "Probe YCenter,XEdge", eTG_EndMill, eST_Milling) udfo_ycenter_xedge.AddAttributeDefinition2 eAID_Priority Dim xcenter_yedge_drop(1) As String xcenter_yedge_drop(0) = "Top" xcenter_yedge_drop(1) = "Bottom" Set udfr_xcenter_yedge = Application.RegisterUserFeature( "Probing:XCenter,YEdge", eST_Milling, "probing_xcenter_yedge", eUDF_PickLocation) xcye_yedge = udfr_xcenter_yedge.AddDataDefinition ( "Y loc. for X center pickup", eUDT_PickY, 0, 0) xcye_xedge = udfr_xcenter_yedge.AddDataDefinition ( "X loc. for Y edge pickup", eUDT_PickX, 0, 0) xcye_edge = udfr_xcenter_yedge.AddDataDefinition ( "Type", eUDT_DropList, 0, 0, xcenter_yedge_drop) udfr_xcenter_yedge.AddDataDefinition ( "",eUDT_None,"","") xcye_surf_loc = udfr_xcenter_yedge.AddDataDefinition ( "XYZ loc. for surface pickup", eUDT_PickPoint, "0,0,0", "0,0,0") udfr_xcenter_yedge.AddDataDefinition ( "",eUDT_None,"","") xcye_zdepth = udfr_xcenter_yedge.AddDataDefinition ( "Probe Z depth for edge pickup", eUDT_Double, -.2, 6) xcye_zclear = udfr_xcenter_yedge.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) xcye_zfind = udfr_xcenter_yedge.AddDataDefinition ( "Probe Z edge hit clearance",eUDT_Double, 2.8,75) udfr_xcenter_yedge.AddDataDefinition ( "",eUDT_None,"","") udfr_xcenter_yedge.AddDataDefinition ( "",eUDT_None,"","") udfr_xcenter_yedge.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_xcenter_yedge = Application.RegisterUserOperation( "Probe XCenter,YEdge", "Probe XCenter,YEdge", eTG_EndMill, eST_Milling) udfo_xcenter_yedge.AddAttributeDefinition2 eAID_Priority Set udfr_zsurface = Application.RegisterUserFeature( "Probing:Z Surface", eST_Milling, "probing_zsurface", eUDF_PickLocation) zs_surf_loc = udfr_zsurface.AddDataDefinition ( "XYZ loc. for surface pickup", eUDT_PickPoint, "0,0,0", "0,0,0") udfr_zsurface.AddDataDefinition ( "",eUDT_None,"","") zs_zclear = udfr_zsurface.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) zs_zfind = udfr_zsurface.AddDataDefinition ( "Probe Z edge hit clearance",eUDT_Double, 3.0,75) udfr_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_zsurface.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_zsurface = Application.RegisterUserOperation( "Probe Z Surface", "Probe Z Surface", eTG_EndMill, eST_Milling) udfo_zsurface.AddAttributeDefinition2 eAID_Priority Dim yedge_drop(1) As String yedge_drop(0) = "Top" yedge_drop(1) = "Bottom" Set udfr_yedge = Application.RegisterUserFeature( "Probing:Y Edge", eST_Milling, "probing_yedge", eUDF_PickLocation) ye_xedge = udfr_yedge.AddDataDefinition ( "X loc. for Y edge pickup", eUDT_PickX, 0, 0) ye_edge = udfr_yedge.AddDataDefinition ( "Type", eUDT_DropList, 0, 0, yedge_drop) udfr_yedge.AddDataDefinition ( "",eUDT_None,"","") ye_zdepth = udfr_yedge.AddDataDefinition ( "Probe Z depth for edge pickup", eUDT_Double, -.2, 6) ye_zclear = udfr_yedge.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) ye_zfind = udfr_yedge.AddDataDefinition ( "Probe Z edge hit clearance",eUDT_Double, 2.8,75) udfr_yedge.AddDataDefinition ( "",eUDT_None,"","") udfr_yedge.AddDataDefinition ( "",eUDT_None,"","") udfr_yedge.AddDataDefinition ( "",eUDT_None,"","") udfr_yedge.AddDataDefinition ( "",eUDT_None,"","") udfr_yedge.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_yedge = Application.RegisterUserOperation( "Probe Y Edge", "Probe Y Edge", eTG_EndMill, eST_Milling) udfo_yedge.AddAttributeDefinition2 eAID_Priority Dim xedge_drop(1) As String xedge_drop(0) = "Left" xedge_drop(1) = "Right" Set udfr_xedge = Application.RegisterUserFeature( "Probing:X Edge", eST_Milling, "probing_xedge") xe_yedge = udfr_xedge.AddDataDefinition ( "Y loc. for X edge pickup", eUDT_PickY, 0, 0) xe_edge = udfr_xedge.AddDataDefinition ( "Type", eUDT_DropList, 0, 0, xedge_drop) udfr_xedge.AddDataDefinition ( "",eUDT_None,"","") xe_zdepth = udfr_xedge.AddDataDefinition ( "Probe Z depth for edge pickup", eUDT_Double, -.2, 6) xe_zclear = udfr_xedge.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) xe_zfind = udfr_xedge.AddDataDefinition ( "Probe Z edge hit clearance",eUDT_Double, 2.8,75) udfr_xedge.AddDataDefinition ( "",eUDT_None,"","") udfr_xedge.AddDataDefinition ( "",eUDT_None,"","") udfr_xedge.AddDataDefinition ( "",eUDT_None,"","") udfr_xedge.AddDataDefinition ( "",eUDT_None,"","") udfr_xedge.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_xedge = Application.RegisterUserOperation( "Probe X Edge", "Probe X Edge", eTG_EndMill, eST_Milling) udfo_xedge.AddAttributeDefinition2 eAID_Priority Dim c_type_drop(1) As String, c_corner_drop (3) As String c_type_drop(0) = "Inside corner" c_type_drop(1) = "Outside corner" c_corner_drop(0) = "Corner #1" c_corner_drop(1) = "Corner #2" c_corner_drop(2) = "Corner #3" c_corner_drop(3) = "Corner #4" Set udfr_corner = Application.RegisterUserFeature( "Probing:Corner", eST_Milling, "probing_corner") c_type = udfr_corner.AddDataDefinition ( "Type", eUDT_DropList, 0, 0, c_type_drop) c_corner = udfr_corner.AddDataDefinition ( "Corner", eUDT_DropList, 0, 0, c_corner_drop) c_corner_loc = udfr_corner.AddDataDefinition ( "XYZ loc. of corner", eUDT_PickPoint, "0,0,0", "0,0,0") c_surf_loc = udfr_corner.AddDataDefinition ( "XYZ loc. of surface", eUDT_PickPoint, "0,0,0", "0,0,0") c_zdepth = udfr_corner.AddDataDefinition ( "Probe Z depth for edge pickup", eUDT_Double, -.2, 6) c_zclear = udfr_corner.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) c_zfind = udfr_corner.AddDataDefinition ( "Probe Z top clearance",eUDT_Double, 5,125) udfr_corner.AddDataDefinition ( "",eUDT_None,"","") udfr_corner.AddDataDefinition ( "",eUDT_None,"","") udfr_corner.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_corner = Application.RegisterUserOperation( "Probe Corner", "Probe Corner", eTG_EndMill, eST_Milling) udfo_corner.AddAttributeDefinition2 eAID_Priority Set udfr_boss = Application.RegisterUserFeature( "Probing:Boss", eST_Milling, "probing_boss") b_surf_loc = udfr_boss.AddDataDefinition ( "XYZ loc. of surface", eUDT_PickPoint, "0,0,0", "0,0,0") b_zdepth = udfr_boss.AddDataDefinition ( "Probe Z depth for hit detection", eUDT_Double, -1.0, -25) b_zclear = udfr_boss.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) b_zfind = udfr_boss.AddDataDefinition ( "Probe Z ????",eUDT_Double, -.75,-20) b_dia = udfr_boss.AddDataDefinition ( "Boss Dia.",eUDT_Double,1,20) udfr_boss.AddDataDefinition ( "",eUDT_None,"","") udfr_boss.AddDataDefinition ( "",eUDT_None,"","") udfr_boss.AddDataDefinition ( "",eUDT_None,"","") udfr_boss.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_boss = Application.RegisterUserOperation( "Probe Boss", "Probe Boss", eTG_EndMill, eST_Milling) udfo_boss.AddAttributeDefinition2 eAID_Priority Set udfr_hole = Application.RegisterUserFeature( "Probing:Hole", eST_Milling, "probing_hole") h_surf_loc = udfr_hole.AddDataDefinition ( "XYZ loc. of surface", eUDT_PickPoint, "0,0,0", "0,0,0") h_zdepth = udfr_hole.AddDataDefinition ( "Probe Z depth for hit detection", eUDT_Double, -1.0, -25) h_zclear = udfr_hole.AddDataDefinition ( "Probe Z clearance distance", eUDT_Double, .5, 15) h_zfind = udfr_hole.AddDataDefinition ( "Probe Z ????",eUDT_Double, -.75,-20) h_dia = udfr_hole.AddDataDefinition ( "Hole Dia.",eUDT_Double,1,20) udfr_hole.AddDataDefinition ( "",eUDT_None,"","") udfr_hole.AddDataDefinition ( "",eUDT_None,"","") udfr_hole.AddDataDefinition ( "",eUDT_None,"","") udfr_hole.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_hole = Application.RegisterUserOperation( "Probe Hole", "Probe Hole", eTG_EndMill, eST_Milling) udfo_hole.AddAttributeDefinition2 eAID_Priority Dim Lzs_type_drop(1) As String Lzs_type_drop(0) = "Right side pickup" Lzs_type_drop(1) = "Left side pickup" Set udfr_L_zsurface = Application.RegisterUserFeature( "Probing:Turn Z Surface", eST_Turning, "probing_zsurface") Lzs_type = udfr_L_zsurface.AddDataDefinition ( "Type", eUDT_DropList, 0, 0, Lzs_type_drop) Lzs_xedge = udfr_L_zsurface.AddDataDefinition ( "X loc. for Z edge pickup", eUDT_PickX, 0, 0) Lzs_setup_origin = udfr_L_zsurface.AddDataDefinition ( "Setup Origin", eUDT_PickZ, 0, 0) udfr_L_zsurface.AddDataDefinition ( "",eUDT_None,"","") Lzs_stkover = udfr_L_zsurface.AddDataDefinition ( "Stock oversize amount", eUDT_Double, .062, 1.5) udfr_L_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_L_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_L_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_L_zsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_L_zsurface.AddDataDefinition ( "Version", eUDT_StaticString, "1.00", "1.00") Set udfo_L_zsurface = Application.RegisterUserOperation( "Probe Turn Z Surface", "Probe Z Surface", eTG_EndMill, eST_Turning) udfo_L_zsurface.AddAttributeDefinition2 eAID_Priority Set udfr_L_zcenter_xsurface = Application.RegisterUserFeature( "Probing:Turn Z Center, X Surface", eST_Turning, "probing_zcenter_xsurface") Lzcxs_xedge = udfr_L_zcenter_xsurface.AddDataDefinition ( "X loc. for right side Z edge pickup", eUDT_PickX, 0, 0) Lzcxs_xedge2 = udfr_L_zcenter_xsurface.AddDataDefinition ( "X loc. for left side Z edge pickup", eUDT_PickX, 0, 0) Lzcxs_finishl = udfr_L_zcenter_xsurface.AddDataDefinition ( "Finish length ", eUDT_Double, 4, 100) udfr_L_zcenter_xsurface.AddDataDefinition ( "",eUDT_None,"","") Lzcxs_stkover = udfr_L_zcenter_xsurface.AddDataDefinition ( "Stock oversize amount", eUDT_Double, .062, 1.5) udfr_L_zcenter_xsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_L_zcenter_xsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_L_zcenter_xsurface.AddDataDefinition ( "",eUDT_None,"","") udfr_L_zcenter_xsurface.AddDataDefinition ( "Version", eUDT_StaticString, "1.01", "1.01") Set udfo_L_zcenter_xsurface = Application.RegisterUserOperation( "Probe Turn Z Center, X Surface", "Probe Z Center, X Surface", eTG_EndMill, eST_Turning) udfo_L_zcenter_xsurface.AddAttributeDefinition2 eAID_Priority If flags = eAIF_ConnectUserLoad Then Dim Doc As FMDocument For Each Doc In Application.Documents Doc.InvalidateToolpaths Next Doc End If unloading = False End Sub ' this event handler is executed when the addin is unloaded. ' this occurs if you uncheck the checkbox in the addins dialog or ' when featurecam exits. ' notice that we invalidate toolpaths in all documents whenever you unload this addin. Private Sub AddIn_OnDisConnect(ByVal flags As FeatureCAM.tagFMAddInFlags) Set udfr_xycenter = Nothing Set udfo_xycenter = Nothing Set udfr_ycenter_xedge = Nothing Set udfo_ycenter_xedge = Nothing Set udfr_xcenter_yedge = Nothing Set udfo_xcenter_yedge = Nothing Set udfr_zsurface = Nothing Set udfo_zsurface = Nothing Set udfr_yedge = Nothing Set udfo_yedge = Nothing Set udfr_xedge = Nothing Set udfo_xedge = Nothing Set udfr_corner = Nothing Set udfo_corner = Nothing Set udfr_boss = Nothing Set udfo_boss = Nothing Set udfr_hole = Nothing Set udfo_hole = Nothing Set udfr_L_zsurface = Nothing Set udfo_L_zsurface = Nothing Set udfr_L_zcenter_xsurface = Nothing Set udfo_L_zcenter_xsurface = Nothing unloading = True If flags = eAIF_DisConnectUserUnLoad Then Dim Doc As FMDocument For Each Doc In Application.Documents Doc.InvalidateToolpaths Next Doc End If End Sub ' this event handler is called whenever the user makes a change to the UDF parameters. ' Private Sub Application_UserFeatureVerify(Doc As FeatureCAM.FMDocument, UDF As FeatureCAM.FMUserFeature, _ valid As Variant, error_message As String) Dim UDO As FMUserOperation Dim xyz_surf As String, probe_z_depth As Double, probe_z_clear As Double, probe_zfind As Double Dim xy_edge_x As Double, xy_edge_y As Double, xy_edge_z As Double Dim xyz_surf_x As Double, xyz_surf_y As Double, xyz_surf_z As Double Dim corner_type As Long, which_corner As Long, xyz_corner As String Dim stk_oversize As Double, xy_edge_x2 As Double Dim hole_dia As Double, finish_length As Double Dim edge_type As Long If( UDF.RegisteredName = udfr_xycenter.Name ) Then xy_edge_x = UDF.GetData( xy_xedge) xy_edge_y = UDF.GetData( xy_yedge) xyz_surf = UDF.GetData( xy_surf_loc) probe_z_depth = UDF.GetData( xy_zdepth) probe_z_clear = UDF.GetData( xy_zclear) ConvertNumberstringToNumbers(xyz_surf), xyz_surf_x, xyz_surf_y, xyz_surf_z UDF.SetLocation( xy_edge_x, xy_edge_y, 0.0) Set UDO = UDF.AddUserOperation ( udfo_xycenter.Name, xy_edge_x, xy_edge_y, xyz_surf_x, xyz_surf_y, xyz_surf_z, _ probe_z_depth, probe_z_clear ) valid = True If valid Then ' make the cross section of the bore and display some wireframe geometry 'UDF.AddCrossSectionLinear( radius, 0) 'UDF.AddCrossSectionLinear( radius, -Depth ) 'UDF.AddCrossSectionLinear( 0, -Depth) End If ElseIf( UDF.RegisteredName = udfr_ycenter_xedge.Name ) Then xy_edge_x = UDF.GetData( ycxe_xedge) xy_edge_y = UDF.GetData( ycxe_yedge) xyz_surf = UDF.GetData( ycxe_surf_loc) probe_z_depth = UDF.GetData( ycxe_zdepth) probe_z_clear = UDF.GetData( ycxe_zclear) probe_zfind = UDF.GetData( ycxe_zfind) edge_type = UDF.GetData( ycxe_edge) ConvertNumberstringToNumbers(xyz_surf), xyz_surf_x, xyz_surf_y, xyz_surf_z UDF.SetLocation( xy_edge_x, xy_edge_y, 0.0) Set UDO = UDF.AddUserOperation ( udfo_ycenter_xedge.Name, xy_edge_x, xy_edge_y, xyz_surf_x, xyz_surf_y, xyz_surf_z, _ probe_z_depth, probe_z_clear, probe_zfind, edge_type) valid = True ElseIf( UDF.RegisteredName = udfr_xcenter_yedge.Name ) Then xy_edge_x = UDF.GetData( xcye_xedge) xy_edge_y = UDF.GetData( xcye_yedge) xyz_surf = UDF.GetData( xcye_surf_loc) probe_z_depth = UDF.GetData( xcye_zdepth) probe_z_clear = UDF.GetData( xcye_zclear) probe_zfind = UDF.GetData( xcye_zfind) edge_type = UDF.GetData( xcye_edge) ConvertNumberstringToNumbers(xyz_surf), xyz_surf_x, xyz_surf_y, xyz_surf_z UDF.SetLocation( xy_edge_x, xy_edge_y, 0.0) Set UDO = UDF.AddUserOperation ( udfo_xcenter_yedge.Name, xy_edge_x, xy_edge_y, xyz_surf_x, xyz_surf_y, xyz_surf_z, _ probe_z_depth, probe_z_clear, probe_zfind, edge_type) valid = True ElseIf( UDF.RegisteredName = udfr_zsurface.Name ) Then xyz_surf = UDF.GetData( zs_surf_loc) probe_z_clear = UDF.GetData( zs_zclear) probe_zfind = UDF.GetData( zs_zfind) ConvertNumberstringToNumbers(xyz_surf), xyz_surf_x, xyz_surf_y, xyz_surf_z UDF.SetLocation( xyz_surf_x, xyz_surf_y, 0.0) Set UDO = UDF.AddUserOperation ( udfo_zsurface.Name, xyz_surf_x, xyz_surf_y, xyz_surf_z, probe_z_clear, probe_zfind) valid = True ElseIf( UDF.RegisteredName = udfr_yedge.Name ) Then xy_edge_x = UDF.GetData( ye_xedge) probe_z_depth = UDF.GetData( ye_zdepth) probe_z_clear = UDF.GetData( ye_zclear) probe_zfind = UDF.GetData( ye_zfind) edge_type = UDF.GetData( ye_edge) UDF.SetLocation( xy_edge_x, 0.0, 0.0) Set UDO = UDF.AddUserOperation ( udfo_yedge.Name, xy_edge_x, probe_z_depth, probe_z_clear, probe_zfind, edge_type) valid = True ElseIf( UDF.RegisteredName = udfr_xedge.Name ) Then xy_edge_y = UDF.GetData( xe_yedge) probe_z_depth = UDF.GetData( xe_zdepth) probe_z_clear = UDF.GetData( xe_zclear) probe_zfind = UDF.GetData( xe_zfind) edge_type = UDF.GetData( xe_edge) UDF.SetLocation( 0.0, xy_edge_y, 0.0) Set UDO = UDF.AddUserOperation ( udfo_xedge.Name, xy_edge_y, probe_z_depth, probe_z_clear, probe_zfind, edge_type) valid = True ElseIf( UDF.RegisteredName = udfr_corner.Name ) Then corner_type = UDF.GetData( c_type) which_corner = UDF.GetData( c_corner) xyz_corner = UDF.GetData( c_corner_loc) xyz_surf = UDF.GetData( c_surf_loc) probe_z_depth = UDF.GetData( c_zdepth) probe_z_clear = UDF.GetData( c_zclear) probe_zfind = UDF.GetData( c_zfind) ConvertNumberstringToNumbers(xyz_corner), xy_edge_x, xy_edge_y, xy_edge_z ConvertNumberstringToNumbers(xyz_surf), xyz_surf_x, xyz_surf_y, xyz_surf_z UDF.SetLocation( xy_edge_x, xy_edge_y, 0.0) Set UDO = UDF.AddUserOperation ( udfo_corner.Name, corner_type, which_corner, xy_edge_x, xy_edge_y, _ xyz_surf_x, xyz_surf_y, xyz_surf_z, probe_z_depth, probe_z_clear, probe_zfind) valid = True ElseIf( UDF.RegisteredName = udfr_boss.Name ) Then xyz_surf = UDF.GetData( b_surf_loc) probe_z_depth = UDF.GetData( b_zdepth) probe_z_clear = UDF.GetData( b_zclear) probe_zfind = UDF.GetData( b_zfind) hole_dia = UDF.GetData( b_dia) ConvertNumberstringToNumbers(xyz_surf), xyz_surf_x, xyz_surf_y, xyz_surf_z UDF.SetLocation( xyz_surf_x, xyz_surf_y, xyz_surf_z) Set UDO = UDF.AddUserOperation ( udfo_boss.Name, xyz_surf_x, xyz_surf_y, xyz_surf_z, probe_z_depth, probe_z_clear, _ probe_zfind, hole_dia) valid = True ElseIf( UDF.RegisteredName = udfr_hole.Name ) Then xyz_surf = UDF.GetData( h_surf_loc) probe_z_depth = UDF.GetData( h_zdepth) probe_z_clear = UDF.GetData( h_zclear) probe_zfind = UDF.GetData( h_zfind) hole_dia = UDF.GetData( h_dia) ConvertNumberstringToNumbers(xyz_surf), xyz_surf_x, xyz_surf_y, xyz_surf_z UDF.SetLocation( xyz_surf_x, xyz_surf_y, xyz_surf_z) Set UDO = UDF.AddUserOperation ( udfo_hole.Name, xyz_surf_x, xyz_surf_y, xyz_surf_z, probe_z_depth, probe_z_clear, _ probe_zfind, hole_dia) valid = True ElseIf( UDF.RegisteredName = udfr_L_zsurface.Name ) Then xy_edge_x = UDF.GetData( Lzs_xedge) corner_type = UDF.GetData( Lzs_type) xy_edge_z = UDF.GetData( Lzs_setup_origin) stk_oversize = UDF.GetData( Lzs_stkover) Set UDO = UDF.AddUserOperation ( udfo_L_zsurface.Name, corner_type, xy_edge_z, stk_oversize, xy_edge_x) valid = True ElseIf( UDF.RegisteredName = udfr_L_zcenter_xsurface.Name ) Then xy_edge_x = UDF.GetData( Lzcxs_xedge) xy_edge_x2 = UDF.GetData( Lzcxs_xedge2) stk_oversize = UDF.GetData( Lzcxs_stkover) finish_length = UDF.GetData( Lzcxs_finishl) Set UDO = UDF.AddUserOperation ( udfo_L_zcenter_xsurface.Name, xy_edge_x, xy_edge_x2, stk_oversize, finish_length) valid = True End If End Sub Private Sub ConvertNumberstringToNumbers(ByVal num_string As String, ByRef num_string_x As Double, _ ByRef num_string_y As Double, ByRef num_string_z As Double) Dim n_string() As String n_string() = Split(num_string,",") num_string_x = Val(n_string(0)) num_string_y = Val(n_string(1)) num_string_z = Val(n_string(2)) End Sub Private Function FormatD( ByVal D As Double ) As String FormatD = Trim(Format(D,"##0.0###")) End Function Private Sub Application_UserOperationDefaultTool(UDO As FeatureCAM.FMUserOperation, tool_name As String, valid As Variant, Crib As FeatureCAM.FMToolCrib) If( UDO.RegisteredName = udfo_xycenter.Name Or _ UDO.RegisteredName = udfo_ycenter_xedge.Name Or _ UDO.RegisteredName = udfo_xcenter_yedge.Name Or _ UDO.RegisteredName = udfo_zsurface.Name Or _ UDO.RegisteredName = udfo_yedge.Name Or _ UDO.RegisteredName = udfo_xedge.Name Or _ UDO.RegisteredName = udfo_corner.Name Or _ UDO.RegisteredName = udfo_boss.Name Or _ UDO.RegisteredName = udfo_hole.Name Or _ UDO.RegisteredName = udfo_L_zsurface.Name Or _ UDO.RegisteredName = udfo_L_zcenter_xsurface.Name) Then tool_name = "SPINDLE PROBE" valid = True End If End Sub Private Sub Application_UserOperationFeedSpeed(UDO As FeatureCAM.FMUserOperation, Feed As Double, Speed As Double, valid As Variant) If( UDO.RegisteredName = udfo_xycenter.Name Or _ UDO.RegisteredName = udfo_ycenter_xedge.Name Or _ UDO.RegisteredName = udfo_xcenter_yedge.Name Or _ UDO.RegisteredName = udfo_zsurface.Name Or _ UDO.RegisteredName = udfo_yedge.Name Or _ UDO.RegisteredName = udfo_xedge.Name Or _ UDO.RegisteredName = udfo_corner.Name Or _ UDO.RegisteredName = udfo_boss.Name Or _ UDO.RegisteredName = udfo_hole.Name Or _ UDO.RegisteredName = udfo_L_zsurface.Name Or _ UDO.RegisteredName = udfo_L_zcenter_xsurface.Name) Then valid = True Feed = 0 Speed = 0 End If End Sub ' this event handler is called upon in order to compute the toolpath for the UDO ' Private Sub Application_UserOperationToolPath(UDO As FeatureCAM.FMUserOperation, valid As Variant) Dim edge_x As Double, edge_y As Double Dim xyz_surf_x As Double, xyz_surf_y As Double, xyz_surf_z As Double Dim probe_z_depth As Double, probe_z_clear As Double, probe_z_find As Double Dim stock_size_x As Double, stock_size_y As Double, stock_size_z As Double Dim target As Double, probe_pos1 As Double, probe_pos2 As Double Dim text_string As String, corner_type As Long, which_corner As Long, s1 As String, s2 As String Dim setup_origin As Double, stk_oversize As Double, tool_number As Long Dim stock_od As Double, stock_id As Double Dim post_name As String, ext_index As Long Dim Cin_850 As String, Cin_ac2100 As String, Cin_850_2 As String Dim hole_dia As Double, finish_length As Double Dim edge_type As Long Dim minX As Double, minY As Double, maxX As Double, maxY As Double UDO.Document.Application.GetMillPostOptions( post_name) If( TypeName( UDO.Document) = "IFMDocument" And UDO.Document.ActiveSetup.Type = eST_Turning) Then UDO.Document.Application.GetTurnPostOptions( post_name) End If post_name = UCase( post_name) ext_index = InStrRev( post_name, ".CNC") post_name = Left$( post_name, ext_index-1) If( InStrRev( post_name, "\") <> 0) Then post_name = Mid$(post_name,InStrRev( post_name, "\")+1) End If Cin_850 = "850PROBE1" Cin_850_2 = "850PROBE2" Cin_ac2100 = "AC2100PROBE" If( UDO.RegisteredName = udfo_xycenter.Name ) Then valid = True edge_x = UDO.GetArgument(0) edge_y = UDO.GetArgument(1) xyz_surf_x = UDO.GetArgument(2) xyz_surf_y = UDO.GetArgument(3) xyz_surf_z = UDO.GetArgument(4) probe_z_depth = UDO.GetArgument(5) probe_z_clear = UDO.GetArgument(6) UDO.Document.Stock.BoundingBox(minX, minY, ,maxX, maxY,,eCS_CurrentSetup) stock_size_x = maxX - minX stock_size_y = maxY - minY If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, X-Y CENTER PICKUP") UDO.AddPostedText( "G0 X0 Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS,L98 G3 X" + FormatD(edge_x) + " Y" + FormatD(edge_y) + " Z" + FormatD(xyz_surf_z) + _ " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + " K" + FormatD(probe_z_depth) + _ " F" + FormatD(stock_size_x) + " S" + FormatD(stock_size_y) + " R" + FormatD(probe_z_clear) + ")" UDO.AddPostedText(text_string) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, X-Y CENTER PICKUP") UDO.AddPostedText( "G0 X0 Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS,""SUB-98"" G3 X" + FormatD(edge_x) + " Y" + FormatD(edge_y) + " Z" + FormatD(xyz_surf_z) + _ " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + " K" + FormatD(probe_z_depth) + _ " F" + FormatD(stock_size_x) + " S" + FormatD(stock_size_y) + " R" + FormatD(probe_z_clear) + ")" UDO.AddPostedText(text_string) UDO.AddPostedText( "X0 Y0") End If ElseIf( UDO.RegisteredName = udfo_ycenter_xedge.Name ) Then valid = True edge_x = UDO.GetArgument(0) edge_y = UDO.GetArgument(1) xyz_surf_x = UDO.GetArgument(2) xyz_surf_y = UDO.GetArgument(3) xyz_surf_z = UDO.GetArgument(4) probe_z_depth = UDO.GetArgument(5) probe_z_clear = UDO.GetArgument(6) probe_z_find = UDO.GetArgument(7) edge_type = UDO.GetArgument(8) UDO.Document.Stock.BoundingBox(minX, minY, ,maxX, maxY,,eCS_CurrentSetup) stock_size_x = maxX - minX stock_size_y = maxY - minY If( edge_type = 0) Then text_string = "LEFT" target = minX probe_pos1 = target - probe_z_clear probe_pos2 = target + probe_z_clear Else text_string = "RIGHT" target = maxY probe_pos1 = target + probe_z_clear probe_pos2 = target - probe_z_clear End If If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, Y-CENTER W/ " + text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS,L98 G2 X" + FormatD(edge_x) + " Z" + FormatD(xyz_surf_z) + _ " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + " K" + FormatD(probe_z_depth) + _ " S" + FormatD(stock_size_y) + " R" + FormatD(probe_z_clear) + ")" UDO.AddPostedText(text_string) UDO.AddPostedText( "G92 Y0") UDO.AddPostedText( "G0 X" + FormatD(probe_pos1) + " Y" + FormatD(edge_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 X" + FormatD(probe_pos2)) UDO.AddPostedText( "G11E [M25]=1L200") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "Q200 G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "X [M21]") UDO.AddPostedText( "G92 X" + FormatD(target)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, Y-CENTER W/ " + text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS,""SUB-98"" G2 X" + FormatD(edge_x) + " Z" + FormatD(xyz_surf_z) + _ " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + " K" + FormatD(probe_z_depth) + _ " S" + FormatD(stock_size_y) + " R" + FormatD(probe_z_clear) + ")" UDO.AddPostedText(text_string) UDO.AddPostedText( "G92 Y0") UDO.AddPostedText( "G0 X" + FormatD(probe_pos1) + " Y" + FormatD(edge_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 X" + FormatD(probe_pos2)) UDO.AddPostedText( "(IF[$PROBE_HIT]=1 GOTO [LBL_200])") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "[LBL_200] G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "X [$PRB_PART_LOC(X)]") UDO.AddPostedText( "G92 X" + FormatD(target)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_xcenter_yedge.Name ) Then valid = True edge_x = UDO.GetArgument(0) edge_y = UDO.GetArgument(1) xyz_surf_x = UDO.GetArgument(2) xyz_surf_y = UDO.GetArgument(3) xyz_surf_z = UDO.GetArgument(4) probe_z_depth = UDO.GetArgument(5) probe_z_clear = UDO.GetArgument(6) probe_z_find = UDO.GetArgument(7) edge_type = UDO.GetArgument(8) UDO.Document.Stock.BoundingBox(minX, minY, ,maxX, maxY,,eCS_CurrentSetup) stock_size_x = maxX - minX stock_size_y = maxY - minY If( edge_type = 0) Then text_string = "TOP" target = maxY probe_pos1 = target + probe_z_clear probe_pos2 = target - probe_z_clear Else text_string = "BOTTOM" target = minY probe_pos1 = target - probe_z_clear probe_pos2 = target + probe_z_clear End If If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, X-CENTER W/" + text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X0 Y" + FormatD(edge_y)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS,L98 G1 Y" + FormatD(edge_y) + " Z" + FormatD(xyz_surf_z) + _ " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + " K" + FormatD(probe_z_depth) + _ " F" + FormatD(stock_size_x) + " R" + FormatD(probe_z_clear) + ")" UDO.AddPostedText(text_string) UDO.AddPostedText( "G92 X0") UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y" + FormatD(probe_pos1) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 Y" + FormatD(probe_pos2)) UDO.AddPostedText( "G11E [M25]=1L200") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "Q200 G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Y [M22]") UDO.AddPostedText( "G92 Y" + FormatD(target)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, X-CENTER W/" + text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X0 Y" + FormatD(edge_y)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS,""SUB-98"" G1 Y" + FormatD(edge_y) + " Z" + FormatD(xyz_surf_z) + _ " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + " K" + FormatD(probe_z_depth) + _ " F" + FormatD(stock_size_x) + " R" + FormatD(probe_z_clear) + ")" UDO.AddPostedText(text_string) UDO.AddPostedText( "G92 X0") UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y" + FormatD(probe_pos1) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 Y" + FormatD(probe_pos2)) UDO.AddPostedText( "(IF[$PROBE_HIT]=1 GOTO [LBL_200])") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "[LBL_200] G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Y [$PRB_PART_LOC(Y)]") UDO.AddPostedText( "G92 Y" + FormatD(target)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_zsurface.Name ) Then valid = True xyz_surf_x = UDO.GetArgument(0) xyz_surf_y = UDO.GetArgument(1) xyz_surf_z = UDO.GetArgument(2) probe_z_clear = UDO.GetArgument(3) probe_z_find = UDO.GetArgument(4) If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, Z SURFACE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(xyz_surf_x) + " Y" + FormatD(xyz_surf_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G77 Z" + FormatD(-probe_z_clear)) UDO.AddPostedText( "G11E [M25]=1L200") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "Q200 G0 Z [M23] +" + FormatD(probe_z_find)) UDO.AddPostedText( "G92 Z0 +" + FormatD(probe_z_find)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, Z SURFACE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(xyz_surf_x) + " Y" + FormatD(xyz_surf_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G77 Z" + FormatD(-probe_z_clear)) UDO.AddPostedText( "(IF[$PROBE_HIT]=1 GOTO [LBL_200])") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "[LBL_200] G0 Z [$PRB_PART_LOC(Z)] +" + FormatD(probe_z_find)) UDO.AddPostedText( "G92 Z0 +" + FormatD(probe_z_find)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_yedge.Name ) Then valid = True edge_x = UDO.GetArgument(0) probe_z_depth = UDO.GetArgument(1) probe_z_clear = UDO.GetArgument(2) probe_z_find = UDO.GetArgument(3) edge_type = UDO.GetArgument(4) UDO.Document.Stock.BoundingBox(minX, minY, ,maxX, maxY,,eCS_CurrentSetup) If( edge_type = 0) Then text_string = "TOP" target = maxY probe_pos1 = target + probe_z_clear probe_pos2 = target - probe_z_clear Else text_string = "BOTTOM" target = minY probe_pos1 = target - probe_z_clear probe_pos2 = target + probe_z_clear End If If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, " + text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y" + FormatD(probe_pos1) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 Y" + FormatD(probe_pos2)) UDO.AddPostedText( "G11E [M25]=1L200") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "Q200 G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Y [M22]") UDO.AddPostedText( "G92 Y" + FormatD(target)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, " + text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y" + FormatD(probe_pos1) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 Y" + FormatD(probe_pos2)) UDO.AddPostedText( "(IF[$PROBE_HIT]=1 GOTO [LBL_200])") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "[LBL_200] G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Y [$PRB_PART_LOC(Y)]") UDO.AddPostedText( "G92 Y" + FormatD(target)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_xedge.Name ) Then valid = True edge_y = UDO.GetArgument(0) probe_z_depth = UDO.GetArgument(1) probe_z_clear = UDO.GetArgument(2) probe_z_find = UDO.GetArgument(3) edge_type = UDO.GetArgument(4) UDO.Document.Stock.BoundingBox(minX, minY, ,maxX, maxY,,eCS_CurrentSetup) If( edge_type = 0) Then text_string = "LEFT" target = minX probe_pos1 = target - probe_z_clear probe_pos2 = target + probe_z_clear Else text_string = "RIGHT" target = maxX probe_pos1 = target + probe_z_clear probe_pos2 = target - probe_z_clear End If If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, "+ text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(probe_pos1) + " Y" + FormatD(edge_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 X" + FormatD(probe_pos2)) UDO.AddPostedText( "G11E [M25]=1L200") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "Q200 G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "X [M21]") UDO.AddPostedText( "G92 X" + FormatD(target)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, "+ text_string + " EDGE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(probe_pos1) + " Y" + FormatD(edge_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G77 X" + FormatD(probe_pos2)) UDO.AddPostedText( "(IF[$PROBE_HIT]=1 GOTO [LBL_200])") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "[LBL_200] G0 Z" + FormatD(probe_z_find)) UDO.AddPostedText( "X [$PRB_PART_LOC(X)]") UDO.AddPostedText( "G92 X" + FormatD(target)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_corner.Name ) Then valid = True corner_type = UDO.GetArgument(0) which_corner = UDO.GetArgument(1) edge_x = UDO.GetArgument(2) edge_y = UDO.GetArgument(3) xyz_surf_x = UDO.GetArgument(4) xyz_surf_y = UDO.GetArgument(5) xyz_surf_z = UDO.GetArgument(6) probe_z_depth = UDO.GetArgument(7) probe_z_clear = UDO.GetArgument(8) probe_z_find = UDO.GetArgument(9) If( which_corner = 0) Then text_string = "MSG, CORNER #1, " s1 = " G1" ElseIf( which_corner = 1) Then text_string = "MSG, CORNER #2, " s1 = " G2" ElseIf( which_corner = 2) Then text_string = "MSG, CORNER #3, " s1 = " G3" ElseIf( which_corner = 3) Then text_string = "MSG, CORNER #4, " s1 = " G4" End If If( corner_type = 0) Then text_string = text_string + "INSIDE PICKUP" s2 = " F1" Else text_string = text_string + "OUTSIDE PICKUP" s2 = " F0" End If If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,text_string) UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y" + FormatD(edge_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS, L97" + s1 + " X" + FormatD(edge_x) + " Y" + FormatD(edge_y) + _ " Z" + FormatD(xyz_surf_z) + " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + _ " K" + FormatD(probe_z_depth) + s2 + ")" UDO.AddPostedText(text_string) UDO.AddPostedText( "G92 X" + FormatD(edge_x) + " Y" + FormatD(edge_y)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,text_string) UDO.AddPostedText( "G0 X" + FormatD(edge_x) + " Y" + FormatD(edge_y) + " Z" + FormatD(probe_z_find)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) text_string = "(CLS, ""SUB-97""" + s1 + " X" + FormatD(edge_x) + " Y" + FormatD(edge_y) + _ " Z" + FormatD(xyz_surf_z) + " I" + FormatD(xyz_surf_x) + " J" + FormatD(xyz_surf_y) + _ " K" + FormatD(probe_z_depth) + s2 + ")" UDO.AddPostedText(text_string) UDO.AddPostedText( "G92 X" + FormatD(edge_x) + " Y" + FormatD(edge_y)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_boss.Name ) Then valid = True xyz_surf_x = UDO.GetArgument(0) xyz_surf_y = UDO.GetArgument(1) xyz_surf_z = UDO.GetArgument(2) probe_z_depth = UDO.GetArgument(3) probe_z_clear = UDO.GetArgument(4) probe_z_find = UDO.GetArgument(5) hole_dia = UDO.GetArgument(6) If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, BOSS PICKUP") UDO.AddPostedText( "G0 X" + FormatD(xyz_surf_x) + " Y" + FormatD(xyz_surf_y)) UDO.AddPostedText( "Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G77 Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G11E [M25]=1L220") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "Q220 G0 Z [M25] +" + FormatD(probe_z_clear)) UDO.AddPostedText( "G92 Z0+" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 X0 Y0") UDO.AddPostedText( "G78 Z" + FormatD(probe_z_find) + " P"+ FormatD(hole_dia) + " R" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 X [M21] Y [M22]") UDO.AddPostedText( "G92 X0 Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, BOSS PICKUP") UDO.AddPostedText( "G0 X" + FormatD(xyz_surf_x) + " Y" + FormatD(xyz_surf_y)) UDO.AddPostedText( "Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G77 Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "(IF[$PROBE_HIT]=1 GOTO [LBL_220])") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "[LBL_220] G0 Z [$PRB_PART_LOC(Z)] +" + FormatD(probe_z_clear)) UDO.AddPostedText( "G92 Z0+" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 X0 Y0") UDO.AddPostedText( "G78 Z" + FormatD(probe_z_find) + " P"+ FormatD(hole_dia) + " R" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 X [$PRB_PART_LOC(X)] Y [$PRB_PART_LOC(Y)]") UDO.AddPostedText( "G92 X0 Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_hole.Name ) Then valid = True xyz_surf_x = UDO.GetArgument(0) xyz_surf_y = UDO.GetArgument(1) xyz_surf_z = UDO.GetArgument(2) probe_z_depth = UDO.GetArgument(3) probe_z_clear = UDO.GetArgument(4) probe_z_find = UDO.GetArgument(5) hole_dia = UDO.GetArgument(6) If( post_name = Cin_850 Or post_name = Cin_850_2) Then UDO.AddPostedText(,"MSG, HOLE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(xyz_surf_x) + " Y" + FormatD(xyz_surf_y)) UDO.AddPostedText( "Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G77 Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "G11E [M25]=1L220") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "Q220 G0 Z [M23] +" + FormatD(probe_z_clear)) UDO.AddPostedText( "G92 Z0+" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 X0 Y0") UDO.AddPostedText( "G78 Z" + FormatD(probe_z_find) + " P" + FormatD(hole_dia)) UDO.AddPostedText( "G0 X [M21] Y [M22]") UDO.AddPostedText( "G92 X0 Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) ElseIf( post_name = Cin_ac2100 ) Then UDO.AddPostedText(,"MSG, HOLE PICKUP") UDO.AddPostedText( "G0 X" + FormatD(xyz_surf_x) + " Y" + FormatD(xyz_surf_y)) UDO.AddPostedText( "Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G77 Z" + FormatD(probe_z_depth)) UDO.AddPostedText( "(IF[$PROBE_HIT]=1 GOTO [LBL_220])") UDO.AddPostedText(,"MSG, WARNING! NO HIT DETECTED") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "[LBL_220] G0 Z [$PRB_PART_LOC(Z)] +" + FormatD(probe_z_clear)) UDO.AddPostedText( "G92 Z0+" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G0 X0 Y0") UDO.AddPostedText( "G78 Z" + FormatD(probe_z_find) + " P" + FormatD(hole_dia)) UDO.AddPostedText( "G0 X [$PRB_PART_LOC(X)] Y [$PRB_PART_LOC(Y)]") UDO.AddPostedText( "G92 X0 Y0") UDO.AddPostedText( "G0 Z" + FormatD(probe_z_clear)) UDO.AddPostedText( "G98.1 G0 Z[$HIGH_LIMIT(Z)]") End If ElseIf( UDO.RegisteredName = udfo_L_zsurface.Name ) Then valid = True Dim sign As Double UDO.Document.Stock.GetDimensions(,,,, stock_od, stock_id) corner_type = UDO.GetArgument(0) setup_origin = UDO.GetArgument(1) stk_oversize = UDO.GetArgument(2) edge_x = UDO.GetArgument(3) ' WARNING: This is a bit of a hack since we need the tool slot at toolpath generation time ' but the actual tool slot assignment is done in featurecam at post time. Assume ' that the user is always going to use the default tool slot for the probe. tool_number = UDO.Tool.DefToolSlot sign = 1.0 If( corner_type = 1) Then sign = -1.0 UDO.AddPostedText(,"MSG, Z SURFACE PICKUP") UDO.AddPostedText( ":G0 G98 X [M3] - [M15] - [M40] Z [M4] - [M16] - [M41]") UDO.AddPostedText(,"MSG, CHANGE INBOARD PICKUP COORDINATE HERE-REGSTER T25") UDO.AddPostedText( "G10 = [T25] V" + FormatD(setup_origin)) UDO.AddPostedText(,"MSG, BLANK DIAMETER SHOULD BE " + FormatD(stock_od)) UDO.AddPostedText( "G10 = [T20] V" + FormatD(stock_od)) UDO.AddPostedText( "G10 = [T21] V" + FormatD(stk_oversize)) UDO.AddPostedText(,"MSG, PROBE SHOULD BE MANUALLY INDEXED AND POS. AT Z0") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "(SLO, G11 X" + FormatD(stock_id/2.0) + "+[TFO," + CStr(tool_number) + ",X]/2+.1 Z1.75+[TFO," + CStr(tool_number) + ",Z])") UDO.AddPostedText( "(SHI, G11 X5.2756 Z20.8660)") UDO.AddPostedText( "(SLO, G12 X" + FormatD(stock_id/2.0) + "+[TFO," + CStr(tool_number) + ",X]/2+.01 Z2.75+" + FormatD(mandrel(stock_id)) + "+[TFO," + CStr(tool_number) + ",Z])") UDO.AddPostedText( "(SHI, G12 X2.75+[TFO," + CStr(tool_number) + ",X] Z20.8661)") UDO.AddPostedText( "G10 = [T29] V [M4] + [M6] - [TFO," + CStr(tool_number) + ",Z]") UDO.AddPostedText( "G0 G98 X5.2753 - [M15] - [M40]") UDO.AddPostedText( "G0 H0 M26 T" + CStr(tool_number)) UDO.AddPostedText( "G0 G98 X5.2753 - [M15] - [M40]") UDO.AddPostedText( "G0 Z" + FormatD(sign*0.5) + " + [T29]") UDO.AddPostedText( "X"+FormatD(edge_x)) UDO.AddPostedText( "G77 Z" + FormatD(sign*-0.5) + " + [T29]") UDO.AddPostedText(,"MSG, NOW PICKING UP EDGE OF BLANK FOR THE FIRST TIME") UDO.AddPostedText( "G11E [M13] = 1L200") UDO.AddPostedText( "Q111") UDO.AddPostedText(,"MSG,") UDO.AddPostedText( "G04 F.5") UDO.AddPostedText(,"MSG, WARNING ! NO HIT DETECTED ON FIRST TRY") UDO.AddPostedText( "G04 F1.0") UDO.AddPostedText( "G11L-111") UDO.AddPostedText( "Q200 G04 F.5") UDO.AddPostedText( "G77 Z" + FormatD(sign*-.020) + " + [M49]") UDO.AddPostedText(,"MSG, NOW PICKING UP EDGE OF BLANK A 2ND TIME") UDO.AddPostedText( "G11E [M13] = 1L200") UDO.AddPostedText( "Q111") UDO.AddPostedText(,"MSG,") UDO.AddPostedText( "G04 F.5") UDO.AddPostedText(,"MSG, WARNING ! NO HIT DETECTED ON 2ND TRY") UDO.AddPostedText( "G04 F1.0") UDO.AddPostedText( "G11L-111") UDO.AddPostedText( "Q200") UDO.AddPostedText( "G0 Z0.5 + [T29]") UDO.AddPostedText( "G0 G98 X5.2753 - [M15] - [M40]") UDO.AddPostedText( "Z [M49]") UDO.AddPostedText( "G92 Z [T25]") ElseIf( UDO.RegisteredName = udfo_L_zcenter_xsurface.Name ) Then valid = True Dim stock_len As Double Dim edge_x2 As Double UDO.Document.Stock.GetDimensions(,stock_len,,, stock_od, stock_id) edge_x = UDO.GetArgument(0) edge_x2 = UDO.GetArgument(1) stk_oversize = UDO.GetArgument(2) finish_length = UDO.GetArgument(3) ' WARNING: This is a bit of a hack since we need the tool slot at toolpath generation time ' but the actual tool slot assignment is done in featurecam at post time. Assume ' that the user is always going to use the default tool slot for the probe. tool_number = UDO.Tool.DefToolSlot UDO.AddPostedText(,"MSG, Z CENTER WITH X SURFACE PICKUP") UDO.AddPostedText( ":G0 G98 X [M3] - [M15] - [M40] Z [M4] - [M16] - [M41]") UDO.AddPostedText(,"MSG, BLANK DIAMETER SHOULD BE " + FormatD(stock_od)) UDO.AddPostedText(,"MSG, BLANK WIDTH SHOULD BE " + FormatD(stock_len)) UDO.AddPostedText(,"MSG, PROGRAMED MANDREL SIZE IS " + FormatD(stock_id) + " DIA X " + FormatD(mandrel(stock_id)) +" LONG") UDO.AddPostedText(,"MSG, INBOARD SIDE IS TOWARD THE TAILSTOCK") UDO.AddPostedText(,"MSG, PROBE SHOULD BE MANUALY INDEXED AND POS. AT Z0") UDO.AddPostedText( "G0 M00") UDO.AddPostedText( "(SLO, G11 X" + FormatD(stock_id/2.0) + "+[TFO," + CStr(tool_number) + ",X]/2+.1 Z1.75+[TFO," + CStr(tool_number) + ",Z])") UDO.AddPostedText( "(SHI, G11 X5.2756 Z20.8660)") UDO.AddPostedText( "(SLO, G12 X" + FormatD(stock_id/2.0) + "+[TFO," + CStr(tool_number) + ",X]/2+.01 Z2.75+" + FormatD(mandrel(stock_id)) + "+[TFO," + CStr(tool_number) + ",Z])") UDO.AddPostedText( "(SHI, G12 X2.75+[TFO," + CStr(tool_number) + ",X] Z20.8661)") UDO.AddPostedText( "G10 = [T20] V" + FormatD(stock_od)) UDO.AddPostedText( "G10 = [T21] V" + FormatD(stk_oversize)) UDO.AddPostedText( "(CLS, L99 G1 X" + FormatD(edge_x) + " Z.0 I" + FormatD(edge_x2) + " K-" + FormatD(finish_length) + ")") End If End Sub Private Function mandrel( stock_id As Double) If( stock_id = 0) Then mandrel = 12.0 ElseIf( stock_id <= .5) Then mandrel = 5.0 ElseIf( stock_id <= .5625) Then mandrel = 5.25 ElseIf( stock_id <= .625) Then mandrel = 5.5 ElseIf( stock_id <= .6875) Then mandrel = 5.75 ElseIf( stock_id <= .75) Then mandrel = 6.0 ElseIf( stock_id <= .8125) Then mandrel = 6.25 ElseIf( stock_id <= .875) Then mandrel = 6.5 ElseIf( stock_id <= .9375) Then mandrel = 6.75 ElseIf( stock_id <= 1.0) Then mandrel = 7.0 ElseIf( stock_id <= 1.125) Then mandrel = 7.5 ElseIf( stock_id <= 1.1875) Then mandrel = 7.75 ElseIf( stock_id <= 1.25) Then mandrel = 8.0 ElseIf( stock_id <= 1.375) Then mandrel = 8.5 ElseIf( stock_id <= 1.5) Then mandrel = 9.0 ElseIf( stock_id <= 1.625) Then mandrel = 9.5 ElseIf( stock_id <= 1.75) Then mandrel = 10.0 ElseIf( stock_id <= 1.875) Then mandrel = 10.5 ElseIf( stock_id <= 2.125) Then mandrel = 11.5 Else mandrel = 12.0 End If End Function Private Sub OpenNcFiles(ByVal nc_file_name As String, temp_file_name As String) ' get a temp file name Dim extension_index As Integer nc_file_name = UCase( nc_file_name) extension_index = InStrRev( nc_file_name, ".TXT") ' find file name temp_file_name = Left$( nc_file_name, extension_index-1) + ".tmp" ' add tmp extension ' open nc file and temp file as read and write Open nc_file_name For Input As #1 ' open the nc code for reading Open temp_file_name For Output As #2 ' open the tmp file for writing End Sub Private Function SearchNcForWord( ByVal search_word As String, buffer As String ) SearchNcForWord = False While Not EOF(1) Line Input #1, buffer ' read line from nc code file, If( InStrRev( buffer, search_word) = 0) Then ' test for word in buffer string Print #2, buffer ' write to temp file Else SearchNcForWord = True Exit Function End If Wend End Function Private Sub CompleteRestOfFile( nc_file_name As String, temp_file_name As String ) Dim buffer As String While Not EOF(1) Line Input #1,buffer Print #2, buffer Wend ' close files Close #1 Close #2 Kill nc_file_name FileCopy( temp_file_name, nc_file_name) Kill temp_file_name End Sub ' ReplaceMillToolLength. Adds tool length program to the end of the NC code output for milling setups ' ' - Searches for the key word "TOOL-LEN-PGM" in the nc code file. The tool length sub program is ' inserted at this point. ' - The tool length for each tool used in the program is set. The tool specific text for each tool ' is stored in the tool comment field. The tool specific text for each tool will be entered by ' Cardinal Mfg. The tool number will be substituted for #N#. Some typical entries might be: ' ' - Tool that depends on the T10 tool angle to set the tool length ' G10=[T10]V180 ' G10=[TWR,#N#,X]V(-.5)*1*[COS([T10])] ' G10=[TWR,#N#,X]V(-.5)*1*[SIN([T10])] ' ' - Tool that can set the tool length directly ' G10=[TDA,#N#,D]V0.250 ' G10=[TWR,#N#,X]V0 ' G10=[TWR,#N#,Y]V0 Private Sub ReplaceMillToolLength( Doc As FeatureCAM.MFGDocument, ByVal nc_file_name As String) Dim tool As FMToolMap Dim buffer As String, temp_file_name As String Dim start As Long, c As String OpenNcFiles nc_file_name, temp_file_name If( SearchNcForWord("TOOL-LEN-PGM", buffer)) Then Print #2, "" Print #2, ":G0" Print #2, "(MSG, TOOL SETTING PGM)" Print #2, "G68" Print #2, "(MSG, MODIFY [T10]'S TO EACH TOOLS SETTING ANG, 180 DEG <---)" For Each tool In Doc.ToolMaps If( tool.Tool <> "SPINDLE PROBE" ) Then Print #2, "/G0M00" Print #2, "(MSG, NOW SETTING TOOL #" + CStr(tool.ToolNumber) + " " + tool.Tool + ")" Print #2, ":G0T" + CStr(tool.ToolNumber) + "M6" buffer = tool.Tool.Comment ' eat trailing LFCR if found c = Right( buffer, 1) If( c = vbLf) Then buffer = Left( buffer, Len(buffer)-1) c = Right( buffer, 1) If( c = vbCr) Then buffer = Left( buffer, Len(buffer)-1) ' check for tool number substring start = InStr( buffer, "#N#" ) If( start = 0) Then Print #2, "(MSG, WARNING!!! TOOL COMMENT NOT SET)" Else ' replace each tool number substring with the actual tool number Do Print #2, Left( buffer, start-1); Print #2, CStr(tool.ToolNumber); buffer = Mid(buffer, start+3) start = InStr( buffer, "#N#" ) Loop While start <> 0 ' output the trailing part of the last line Print #2, buffer End If Print #2, "G68T" + CStr(tool.ToolNumber) + "M6" End If Next tool Print #2, "/G0M00" Print #2, "/G0M2" End If CompleteRestOfFile nc_file_name, temp_file_name End Sub ' ReplaceTurnToolComment. Adds workpiece definition to each tool change format for turning setups ' ' - Searches for the key word "#SLO-SHI#" in the nc code file. The workpiece definition is ' inserted at this point. ' - Expects the "#SLO-SHI#" key word to be followed by the tool number ' - Expects the tool specific text to be contained in the tool comment field. The tool number will be ' substituted for #N#, the Mandrel Bore will be substituted for #MB#, and the Mandrel length will ' be substituted for #ML#. ' - A typical tool change format would include ' [eq(,"")] ' #SLO-SHI#, ' ' - A typical tool comment would include ' (SLO, G11 X#MB#+[TFO,#N#,X]/2+.01 Z1.75+[TFO,#N#,Z]) ' (SHI, G11 X5.2756 Z20.8660) ' (SLO, G12 X#MB#+[TFO,#N#,X]/2+.01 Z2.75+#ML#+[TFO,#N#,Z]) ' (SHI, G12 X2.75+[TFO,#N#,X] Z20.8661) ' G10 = [T29] V [M4] + [M6] - [TFO,#N#,Z] ' Private Sub ReplaceTurnToolComment( Doc As FeatureCAM.MFGDocument, ByVal nc_file_name As String) Dim tool As FMToolMap Dim buffer As String, temp_file_name As String, tn_buf As String, mb_buf As String, ml_buf As String, out_buffer As String Dim found_one As Boolean, stock_id As Double Dim start As Long, tool_number As Long Dim maps As FMToolMaps, map As FMToolMap OpenNcFiles nc_file_name, temp_file_name Set maps = Doc.ToolMaps Doc.Stock.GetDimensions(,,,,, stock_id) ml_buf = FormatD(mandrel(stock_id)) mb_buf = FormatD(stock_id/2.0) found_one = True While found_one found_one = SearchNcForWord("#SLO-SHI#", buffer) If( found_one) Then start = InStr( buffer, "," ) tn_buf = Mid( buffer, start+1) tool_number = CLng(tn_buf) For Each map In maps If( tool_number = map.ToolNumber ) Then buffer = map.Tool.Comment buffer = Replace( buffer, "#N#", tn_buf) buffer = Replace( buffer, "#ML#", ml_buf) buffer = Replace( buffer, "#MB#", mb_buf) Print #2, buffer Exit For End If Next map End If Wend CompleteRestOfFile nc_file_name, temp_file_name End Sub Private Sub Application_PostNCCreate(Doc As FeatureCAM.MFGDocument, ByVal nc_file_name As String, ByVal macro_file_cnt As Long, ByVal macro_file_names As Variant) Dim isTurn As Boolean isTurn = False If( TypeName(Doc) = "IFMDocument") Then isTurn = (Doc.ActiveSetup.Type = eST_Turning) End If If( isTurn = True) Then ReplaceTurnToolComment Doc, nc_file_name Else ReplaceMillToolLength Doc, nc_file_name End If End Sub