SavannahG

Define reduced neck tool with VB Net-Hook

Recommended Posts

I've searched and searched and I can not find a property in the Net-Hook API to define the reduced neck diameter and length for an end mill. There's flute, shank, and shoulder, but no reduced neck, Is this missing, or am I missing something?

Share this post


Link to post
Share on other sites

If you are creating a t-slot type tool you could define the shoulder as the portion with the smaller diameter.Thats the one I use.

Share this post


Link to post
Share on other sites

Have you looked at the ToolNetApi.dll that ships with the newer versions of Mastercam? 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

 

 

Share this post


Link to post
Share on other sites

As SavannahG mentions, never versions of Mastercam has an extended API for working with tools and assemblies. I thought there was an example up on our website under the 3rd Party developers .NET developers section, you might want to check that out.

Share this post


Link to post
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

 

Share this post


Link to post
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;
        }
    }
}

 

  • Haha 1

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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