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:

Determining Total Number of Operations


ad1187
 Share

Recommended Posts

Hi all. I'm trying to create a true/false variable for use within my post where 1=all operations have been posted or 0=not all operations have been posted. I'm comfortable writing the logic, but the problem I'm having is determining the total number of operations in a toolpath group regardless of which operations are posted. Being that only operations selected for posting are output to the NCI file, is there any way to "look ahead" to see if any operations exist after the last posted operation? Any help is appreciated! 

Link to comment
Share on other sites

If they all have the same program the software already asks if you want to post all ops.  Is that not effective?

Just shooting from the hip here but you might be able to create two variables, increment one by +1 on every op then set the other =  opinfo(15240,0) of the last op and if they are not equal throw an error. Theoretically, total number of ops should equal the op number of the last op unless my math fails me.  Evaluate it in peof so that if var1 ne var2 = error message.  That's where I'd start if you want it specifically in the post.

Link to comment
Share on other sites
57 minutes ago, jlw™ said:

If they all have the same program the software already asks if you want to post all ops.  Is that not effective?

Just shooting from the hip here but you might be able to create two variables, increment one by +1 on every op then set the other =  opinfo(15240,0) of the last op and if they are not equal throw an error. Theoretically, total number of ops should equal the op number of the last op unless my math fails me.  Evaluate it in peof so that if var1 ne var2 = error message.  That's where I'd start if you want it specifically in the post.

I think that check only works if the first op and last op in the machine group are posted.

Let's say we have 5 op's in a machine group; that check would work if ops 1, 3 and 5 were posted, but wouldn't if ops 1, 2 and 3 were posted.

Link to comment
Share on other sites
40 minutes ago, Colin Gilchrist said:

The easy fix without writing a C-hook or  Net-hook, is to use Select All Operations > Right-click > Change NC Filename.

That way all the Ops have the same name, and you can select 'all ops' and Post. 

But but but, that would mean paying attention and doing your job.....blasphemy!

:lol:

Link to comment
Share on other sites

If you are interested in a NET-Hook solution the below code may help.
 

        public override MCamReturn Run(int param)
        {
            var postArgs = PostingManager.PostProcessorArguments;
            var postArguments = (PostProcessorArgumentsType)postArgs;

            var opID = postArguments.Argument1;
            if(!int.TryParse(opID, out var operationID))
            {
                return MCamReturn.ErrorOccurred;
            }

            var returnArgs = PostingManager.PostProcessorArguments;
            var returnArguments = (PostProcessorArgumentsType)returnArgs;

            if (AllOpsPosted(operationID))
            {
                returnArguments.Argument1 = "1 ";
            }
            else
            {
                returnArguments.Argument1 = "0 ";
            }
          
            PostingManager.PostProcessorArguments = returnArguments;

            return MCamReturn.NoErrors;
        }

        private bool AllOpsPosted(int operationID)
        {
            var currentOperation = SearchManager.GetOperation(operationID);
            var allOperations = SearchManager.GetOperations(currentOperation.GroupNumber);

            foreach (var operation in allOperations)
            {
                if (!operation.Selected)
                {
                    return false;
                }
            }
            return true;
        }

 

Below is a sample post that shows how you would call the NET-Hook.

fs2 4 1 0 1 0

pheader$
      "(--- Start of File ---)", e$
      *e$

psof$
      "(--- Start of File ---)", e$
      *e$
      pAllOpsPosted(op_id$)
      if (allOpsPosted),
      [
        "All operations posted", e$
      ]
      else,
      [
        "Subset of operations posted", e$
      ]
      *e$

peof$
      "(--- End of File ---)", e$

fmt "" 4 opID

dllReturn    : 0
allOpsPosted : no$

sdq              : '"'
sspace           : " "
snoArgument      : "noArg"

sDLLArgs         : ""
sallOpsPostedDLL : "AllOpsPosted.dll"

pAllOpsPosted(opID)
      sDLLArgs = sdq + drs_str(2, opID) + sdq + sspace + sdq + snoArgument + sdq + sspace + sdq + snoArgument + sdq
      dllReturn = dll(sallOpsPostedDLL, sDLLArgs)
      allOpsPosted = rparsngl(spost_arg_0$, 1)

 

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