Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Define reduced neck tool with VB Net-Hook


Recommended Posts

Thank you for the suggestions.

Peter, I'm trying to define a end mill with a relief diameter, so it goes cutter diameter/length, then shoulder diameter/length, then Neck diameter/length, then Shank diameter to Overall length.

Jeff, I'm going by the Net-Hook API reference guide online version of the NET-Hook_v3 Reference. That was what I found in the MasterCam downloads. I'll look into the ToolNetApi. It looks promising.

Link to comment
Share on other sites

Jeff, do you have an example of how to save the tool to the tool manager using the ToolNetApi.dll functions? I have the method for the Mastercam.database EndMillFlatTool class as follows:

    Friend Function CreateEMFlat(P As Integer) As EndMillFlatTool
        ' Define a new tool
        Dim endMill = New EndMillFlatTool(ToolDia(P), ToolRad(P), ToolNum(P), ToolLenOff(P), ToolDiaOff(P), oa_len(P), flute_len(P), shldr_len(P), ToolCmnt(P)) With {
                    .Coolant = CoolantMode.COOL_FLOOD,
                    .Flutes = ToolFlts(P),
                    .MfgToolCode = ToolMfg(P),
                    .PlungeFeed = ToolPlunge(P),
                    .RetractFeed = ToolRetract(P)}

        MessageBox.Show("Neck Relief = " & ToolRel(P))

        ' Commit the tool to the database
        Return If(Not endMill.Commit(), Nothing, endMill)

    End Function

**************************************************************

I've been trying to figure out how to commit the tool using the ToolNetAPI TlToolEndmill class.

    Friend Function CreateEMF(P As Integer) As TlToolEndmill

        ' Define a new tool
        Dim endMill = New TlToolEndmill() With {
                    .OverallDiameter = ToolDia(P),
                    .MfgToolCode = ToolMfg(P),
                    .OverallLength = oa_len(P),
                    .ShoulderDiameter = shldr_len(P),
                    .ShoulderLength = shldr_len(P),
                    .NeckDiameter = ToolRel(P),
                    .Name = ToolName(P)}

        Return ???

    End Function

 

 

Link to comment
Share on other sites
13 hours ago, SavannahG said:

Jeff, do you have an example of how to save the tool to the tool manager using the ToolNetApi.dll functions? I have the method for the Mastercam.database EndMillFlatTool class as follows:

    Friend Function CreateEMFlat(P As Integer) As EndMillFlatTool
        ' Define a new tool
        Dim endMill = New EndMillFlatTool(ToolDia(P), ToolRad(P), ToolNum(P), ToolLenOff(P), ToolDiaOff(P), oa_len(P), flute_len(P), shldr_len(P), ToolCmnt(P)) With {
                    .Coolant = CoolantMode.COOL_FLOOD,
                    .Flutes = ToolFlts(P),
                    .MfgToolCode = ToolMfg(P),
                    .PlungeFeed = ToolPlunge(P),
                    .RetractFeed = ToolRetract(P)}

        MessageBox.Show("Neck Relief = " & ToolRel(P))

        ' Commit the tool to the database
        Return If(Not endMill.Commit(), Nothing, endMill)

    End Function

**************************************************************

I've been trying to figure out how to commit the tool using the ToolNetAPI TlToolEndmill class.

    Friend Function CreateEMF(P As Integer) As TlToolEndmill

        ' Define a new tool
        Dim endMill = New TlToolEndmill() With {
                    .OverallDiameter = ToolDia(P),
                    .MfgToolCode = ToolMfg(P),
                    .OverallLength = oa_len(P),
                    .ShoulderDiameter = shldr_len(P),
                    .ShoulderLength = shldr_len(P),
                    .NeckDiameter = ToolRel(P),
                    .Name = ToolName(P)}

        Return ???

    End Function

 

 

Look at the chainmanager example for vb.net Under downloads in the services folder there should be an example of the vb function with a return type did you try this :

    Friend Function CreateEMF(P As Integer) As TlToolEndmill


        ' Define a new tool
        Dim endMill = New TlToolEndmill() With {
                    .OverallDiameter = ToolDia(P),
                    .MfgToolCode = ToolMfg(P),
                    .OverallLength = oa_len(P),
                    .ShoulderDiameter = shldr_len(P),
                    .ShoulderLength = shldr_len(P),
                    .NeckDiameter = ToolRel(P),
                    .Name = ToolName(P)}

        Return If(Not TlToolEndmill.Commit(), Nothing, TlToolEndmill)


    End Function

 

Link to comment
Share on other sites

I'm allergic to VB.Net's syntax; below is a (very) basic c# example.

namespace ToolNetApiExample
{
    using Mastercam.App;
    using Mastercam.App.Types;

    using Cnc.Tool.Interop;

    public class Main : NetHook3App
    {
        public override MCamReturn Run(int param)
        {
            var toolSystem = TlToolFunctions.GetToolSystem();

            var endMill = new TlToolEndmill()
            {
                Name = "Example .5in Reduced Shank Tool",
                OverallDiameter = .5,
                TruePhysicalLength = 4,
                CuttingDepth = .375,
                ShoulderLength = 2.0,
                ShoulderDiameter = .375,
                ArborDiameter = .5,
                IsMetric = false
            };

            var toolAssembly = new TlAssembly()
            {
                MainTool = endMill,
            };

            toolSystem.Add(toolAssembly);

            return MCamReturn.NoErrors;
        }
    }
}

 

Link to comment
Share on other sites

HOORAY! It works. Thanks Jeff. I spent hours digging through the sample code and never found an example addressing the tool manager using the ToolNetAPI. Your example is exactly what I needed. I just tweaked a few things for VB, and it works. Here's the VB  version, try not to sneeze!

 

   Friend Function CreateEMF(P As Integer) As TlToolEndmill
        Dim toolSystem = TlToolFunctions.GetToolSystem()

        ' Define a new tool
        Dim endMill = New TlToolEndmill() With {
                    .OverallDiameter = ToolDia(P),
                    .MfgToolCode = ToolMfg(P),
                    .OverallLength = oa_len(P),
                    .ShoulderDiameter = shldr_dia(P),
                    .ShoulderLength = shldr_len(P),
                    .NeckDiameter = rel_dia(P),
                    .Name = ToolCmnt(P),
                    .ToolNumber = ToolNum(P),
                    .FluteCount = ToolFlts(P),
                    .DiameterOffsetNum = ToolDiaOff(P),
                    .LengthOffsetNum = ToolLenOff(P),
                    .ShankType = shnk_type(P),
                    .TaperLength = rel_len(P)}


        Dim toolAssembly = New TlAssembly() With {.MainTool = endMill}

        Return If(Not toolSystem.Add(toolAssembly), Nothing, endMill)

    End Function

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...