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:

Zaffin_D

Verified Members
  • Posts

    374
  • Joined

  • Days Won

    1

Posts posted by Zaffin_D

  1. 19 hours ago, Colin Gilchrist said:

    That's no fair Jeff, you're making it too easy on them!

    I really need to get into the new Tool Table stuff, and it looks like this is a good excuse to do that. Thanks for the sample, I'm sure it will be helpful to everyone who likes to play with Posts.

    Yeah, normally I wouldn't post the exact solution, but there aren't many enhanced tool-table examples in the wild. 

     

    19 hours ago, Colin Gilchrist said:

    Can you enlighten me on what the 'regex' function does?

    Jlw hit the nail on the head, it's used for string manipulation.  It's much more powerful than MP's 'legacy' string functions.

     

    14 minutes ago, SlaveCam said:

    Now whoever told you that?! Why disable it in the first place since the user is already being warned when you press the button.

    That key combination is not a something that should be used in most circumstances.  

    That keystroke combination is from V9 when there was no machine and control definition.  With the MD/CD/Post setup it can be dangerous to swap a post in on the fly, especially if the post reads data from the MD/CD.

     

  2. Here you go.

    [POST_VERSION] #DO NOT MOVE OR ALTER THIS LINE# V21.00 P4 E1 W21.00 T1505932414 M21.00 I0 O10
    # ToolList.mcpost
    
    #region Settings
    
    #region User Settings
    
    # Max length of stool_name, used for formatting
    name_length     : 24
    
    # Max length of sassembly_name, used for formatting
    assembly_length : 14
    
    #endregion
    
    #region Post Settings
    
    x_tooltable$ : 1
    newglobal$   : 1
    rotaxtyp$    : 99999
    
    #endregion
    
    #endregion
    
    #region initializations
    
    #region Enumerators
    
    ZERO@            : 0
    ONE@
    TWO@
    
    TOOL_INFO_TABLE@ : 1
    OP_PARAMETERS@   : 0
    
    TOOL_NOT_OUTPUT@ : 1
    
    #endregion
    
    #region Numerics
    
    result          : 0
    op_number       : 0
    
    #region Globals
    
    diameter      = tlrad$
    corner_radius = tcr$
    
    #endregion
    
    #endregion
    
    #region Strings
    
    stool_name     : ""
    sholder_name   : ""
    sassembly_name : ""
    sspaces        : "                                                  "
    sregex         : ""
    
    #endregion
    
    #endregion
    
    #region Formats
    
    #region Statments
    
    fs2 1   0.8 0.8
    fs2 2   0.4 0.3
    fs2 3   1 0 1 0
    
    #endregion
    
    #region Assignments
    
    fmt  ""       3  op_number       ""
    fmt  "     "  3  tt_tool$        "       "
    fmt  ""       3  name_length     ""
    fmt  ""       3  assembly_length ""
    
    fmt  ""       2  diameter        "   "
    fmt  ""       2  corner_radius   "              "
    
    #endregion
    
    #endregion
    
    #region Lookup Tables
    
    fprmtbl 1 4   # TOOL_INFO_TABLE@
            15240 op_number
            20001 stool_name
            20020 sholder_name
            20021 sassembly_name
    
    #endregion
    
    pset_string_length
        sregex = ".{" + drs_str(TWO@, name_length) + "}"
        stool_name = stool_name + sspaces
        stool_name = regex(sregex, stool_name)
    
        sregex = ".{" + drs_str(TWO@, assembly_length) + "}"
        sassembly_name = sassembly_name + sspaces
        sassembly_name = regex(sregex, sassembly_name)
    
    ptooltable$
        if tt_count$ = TOOL_NOT_OUTPUT@,
          [
          result = fprm(TOOL_INFO_TABLE@, OP_PARAMETERS@)
          pset_string_length
          *tt_tool$, stool_name, *diameter, [if corner_radius > ZERO@, *corner_radius, else, "                   "], sassembly_name, sholder_name, e$
          *e$
          ]
    
    pheader$
        "Tool Number   Tool Name               Diameter   Corner Radius     Assembly       Holder", e$
        *e$
        x_tooltable$

     

    • Like 4
  3. I did some thinking and an asynchronous timer is the only thing I came up with.  It works, but I don't like the static half second delay.  I'm hoping someone will jump in with a better solution. 

        Public Overrides Function Run(param As Integer) As MCamReturn
    
            Dim solidsMask = New GeometryMask(False, False, False, False, False, False, True)
            Dim allSolidEntities = SearchManager.GetGeometry(solidsMask)
    
            For Each solidEntity As SolidGeometry In allSolidEntities
    
                solidEntity.Selected = True
                solidEntity.Commit()
    
            Next
    
            If allSolidEntities.Any() Then
    
                Dim timer = New Timers.Timer(500)
                AddHandler timer.Elapsed, AddressOf OnTimedEvent
                timer.AutoReset = False
                timer.Start()
    
                ExternalAppsManager.RunFTCommand("sld_convert_to_surfs")
          
            Else
                DialogManager.Error("No Solids Found", "No Solids Found")
            End If
    
            Return MCamReturn.NoErrors
        End Function
    
        Private Sub OnTimedEvent()
            MastercamWindow.SetFocusToMastercam()
            SendKeys.SendWait("{ENTER}")
            MastercamWindow.SendEscapeKeyPress()
            SendKeys.Flush()
        End Sub

     

  4. Hello eMastercam,

    I've been working on a pet project that I think could be beneficial to some Mastercam users.  Quick Parameters is a NET-hook that consists of a single modeless window displaying a subset of the selected operation's parameters.

    **Please note, this only works for operations that the NET-Hook API knows about.  This means that it will not work on lathe or wire operations.

    To install, copy the files from the QuickParameters.zip archive attached to this post to the following locations;

    • Copy 'Xceed.Wpf.Toolkit.dll' to the Mastercam install directory, typically  'C:\Program Files\Mcam2019' 
    • Copy 'GalaSoft.MvvmLight.dll', 'QuickParameters.dll', and 'QuickParameters.ft' to Mastercam's chook directory, typically  'C:\Program Files\Mcam2019\chooks' 

    You can grab the source on my Githib.

    A brief gif showing it's functionality.

    QuickParameters.gif.7b4467b581e95d683efb589b9665854e.gif

     

    Right-click to customize the display colors.

    Themes.gif.adb19551ef3913e52f006aa0d2aedec1.gif

     

    Feedback of any kind is always helpful.

    QuickParameters.zip

    • Thanks 1
    • Like 4
  5. I took a brief look at this.

    That post has all the logic to output a work offset based on the value of misc integer 1, but the value isn't output anywhere.  Try forcing the string variable sgwcs where ever you want it output.

    Comments are not supported in this post.  It would be simple to add, but I have no idea if that control supports comments.    

  6. Hi Steven,

    I'm not a VB guy, but try the below code.

    For Each wireframeEntity As Geometry In allWireframeEntities

                Select Case wireframeEntity.GetType()

                    Case GetType(PointGeometry)
                        Dim point = CType(wireframeEntity, PointGeometry)
                        point.Color = 110
                        point.Commit()

                    Case GetType(ArcGeometry)
                        Dim arc = CType(wireframeEntity, ArcGeometry)
                        arc.Color = 115
                        arc.Commit()

                    Case GetType(LineGeometry)
                        Dim line = CType(wireframeEntity, LineGeometry)
                        line.Color = 125
                        line.Commit()

                    Case Else

                End Select

            Next

     

     

  7. 1 hour ago, srbeyke said:

    Jeff,

    I must be as dense as a block of lead.  I cannot get my system to allow me to enter the code without

    producing errors.  I am sure this is due to my inexperience with both the MASTERCAM API and the

    VISUAL BASIC 2015 that I am using.

     

    I am attempting to take VBSCRIPTS that have been working well and translate them into nethooks.

    I initially thought it would not be as difficult to translate scripts that were proven to work.

     

    If there Is anything additional you can add It would be very helpful.

     

    best regards,

    Steven

     

     

     

     

    Hi Steven,

    Can you upload your solution here so I can take a look?

  8. I don't use VB.net but here is a C# example that selects all wireframe geometry in a Mastercam file.

    namespace ExampleNetHook
    {
        using System.Linq;
    
        using Mastercam.App;
        using Mastercam.App.Types;
        using Mastercam.Support;
        using Mastercam.IO;
        using Mastercam.Curves;
        using Mastercam.BasicGeometry;
        using Mastercam.Database.Types;
    
        public class Main : NetHook3App
        {
            #region Public Override Methods
    
            /// <summary>
            /// The main entry point for your NETHook.
            /// </summary>
            /// <param name="param">System parameter.</param>
            /// <returns>A <c>MCamReturn</c> return type representing the outcome of your NetHook application.</returns>
            public override MCamReturn Run(int param)
            {
                // Instanciate a GeomtryMask to select only wireframe geometry 
                var wireframeMask = new GeometryMask
                {
                    Points = true,
                    Lines = true,
                    Arcs = true,
                    PSplines = true,
                    xlines = true,
                    Surfs = false,
                    Solids = false
                };
    
                // Get all the wireframe entities in the current Mastercam file
                var allWireframeEntities = SearchManager.GetGeometry(wireframeMask);
    
                // Check if any wireframe entities exist in the allWireframeEntities array
                if (allWireframeEntities.Any())
                {
                    // Iterate through each wireframe entity 
                    foreach (var wireframeEntity in allWireframeEntities)
                    {
                        // Switch on each wireframe entity to determine it's type
                        switch (wireframeEntity)
                        {
                            case PointGeometry point:
                                // Do something with the point geometry
                                break;
    
                            case ArcGeometry arc:
                                // Do something with the arc geometry
                                break;
    
                            case LineGeometry line:
                                // Do something with the line geometry
                                break;
    
                            case NURBSCurveGeometry nurbsCurve:
                                // Do something with the NURBS geometry
                                break;
    
                            case SplineGeometry spline:
                                // Do something with the spline geometry
                                break;
          
                            case null:
                                break;
    
                            default:
                                break;
                        }
                    }
    
                    return MCamReturn.NoErrors;
                }
                else
                {
                    DialogManager.Error("No wireframe found in .mcam file.", "No Wireframe Found");
                    return MCamReturn.ErrorOccurred;
                }           
            }
    
            #endregion
        }
    }

     

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...