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:

Get tplane name


Recommended Posts

Hello,

Would it be possible for the post processor to scan the planes name, find if 1 plane contains a certain string and save the number of that plane that contains the wanted string?

That plane can also be a plane not used by mastercam any operation in mastercam.

I did some searching but could not find anything.

Link to comment
Share on other sites

You can capture the 'Plane name String' in the 'pparameter$' Post Block. It will be one of the '20,000' series parameters.

You can search through a string, for a 'string match', using the 'strstr' function.

So this is certainly possible, and the amount of effort will vary; depending on how well you know the MP Language. As an example, many users would spend hours or even multiple days to figure out all the steps needed to do this. For me, it is around 20 minutes of effort.

 

Link to comment
Share on other sites

Hello Colin,

I know I can find the tool plane name using parameter 20012 in the pparameter$ and pwrttparam$ post blocks. 

But I think this parameter will only output the plane name and not the offset number used.

Also, is the post reading all the planes of mastercam of just the ones used?

I am quite good at the Mp Language.  I did some pretty cool stuff.

 

Edited by Mgrenier
Link to comment
Share on other sites

Hello Jeff,

What we want to do is to get the offset number related to a plane where this plane contains a certain string (MASTER WCS for example). Like in the image bellow, I want to get into a post variable the value of the plane named MASTER WCS.  Of course the plane name that we are going to look for is always going to be MASTER WCS

MASTER WCS.png

In that case the value of the variable in the post would be 59.

 

Regards,

Link to comment
Share on other sites

You can use a NET-Hook to do this, below is a basic example.

The NET-HOOK - 

namespace QueryViews
{
    using System.Linq;

    using Mastercam.App;
    using Mastercam.App.Types;
    using Mastercam.Posting;
    using Mastercam.Posting.Types;
    using Mastercam.Support;
    using Mastercam.Database;

    public class Main : NetHook3App
    {
        #region Public Override Methods

        /// <summary> The main entry point for your QueryViews. </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)
        {
            var postArguments = GetPostArguments();

            var view = GetView(postArguments.Argument1);

            if (view != null)
            {
                SetPostArguments(view.WorkOffsetNumber.ToString(),
                                 view.ViewID.ToString(),
                                 view.ViewOrigin.ToString());

                return MCamReturn.NoErrors;
            }
            else
            {
                SetPostArguments($"-99999",
                                 $"{postArguments.Argument1} NOT FOUND",
                                 $"{postArguments.Argument1} NOT FOUND");

                return MCamReturn.ErrorOccurred;
            }

        }

        private PostProcessorArgumentsType GetPostArguments() 
            => (PostProcessorArgumentsType)PostingManager.PostProcessorArguments;

        private MCView GetView(string name)
            => SearchManager.GetViews()
                            .Where(v => v.ViewName.ToUpper() == name.ToUpper())
                            .Select(v => v).FirstOrDefault();


        private void SetPostArguments(string argumentOne, string argumentTwo, string argumentThree)
        {
            PostProcessorArgumentsType returnArguments;

            returnArguments.Argument1 = argumentOne;
            returnArguments.Argument2 = argumentTwo;
            returnArguments.Argument3 = argumentThree;

            PostingManager.PostProcessorArguments = returnArguments;
        }
           

        #endregion
    }
}

 

The post - 

#region Numeric Variable Initializations

dll_return : 0

#endregion End Numeric Variable Initializations

#region String Variable Initializations

sdq      : '"' # "
sspace   : " "
snone    : "none"
sinvalid : "-99999"


sdll            : "QueryViews.dll"
sdll_args       : ""

#endregion End String Variable Initializations

#region Query Views

sview_name : "TestWCS"

fq 1 sview_name "Enter a View's Name to Query"

pquery_views
      q1
      sdll_args = sdq + sview_name + sdq
      dll_return = dll(sdll, sdll_args)
      
      if spost_arg_0$ <> sinvalid,
            [
            sview_name, "- Found!", e$
            "     Work Offset ->", spost_arg_0$, e$
            "     View ID     ->", spost_arg_1$, e$
            "     Origin      ->", spost_arg_2$, e$
            ]
      else, "ERROR -", spost_arg_1$, e$

#endregion Query Views

psof$
      pquery_views

 

Output -

// TestWCS - Found!
//      Work Offset -> 59
//      View ID     -> 52
//      Origin      -> X0.0000 Y0.0000 Z0.0000

 

  • Like 1
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...