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:

Getting the post arguments into the Nethook


Recommended Posts

Hello,

 

I am trying to run a nethook from a postprocessor. It runs fine with this code inside of a postprocessor:

 

ppost$
 	result = dll(sDLL,sARGS)

sDLL : "C:\Program Files\mcamx5\chooks\MyNethook.dll"
sARGS : ' "Arg1" "Arg2" "Arg3" '

 

The DLL runs OK from within the postprocessor.

 

But I have a problem getting the arguments from the postprocessor into the Nethook.

 

I use thisis code (but I already know that it not OK):

 

       	
      	Mastercam.Posting.Types.PostProcessorArgumentsType PostArgs = new Mastercam.Posting.Types.PostProcessorArgumentsType();

       	System.ValueType PostArgs = Mastercam.Posting.PostingManager.PostProcessorArguments;

      	string PostArgs1 = PostArgs.Argument1;
      	string PostArgs2 = PostArgs.Argument2;
      	string PostArgs3 = PostArgs.Argument3;
      	MessageBox.Show(PostArgs1 + PostArgs2 + PostArgs3, serror);

 

Has anybody been succesful with this?

 

Any code snippets would be greatly appreciated.

 

Best regards

 

Gorazd

Link to comment
Share on other sites

Gorazd,

 

Try this...

 public override MCamReturn Run(int param)
   {
       bool ret = false;

       // PostingManager is a class that contains a single Property -
       // 'PostProcessorArguments' and this property is a "ValueType".
       // So we 'get' the data from this property.         
       ValueType postArgs = PostingManager.PostProcessorArguments;                        

       // Now we cast postArgs (a ValueType) to 'PostProcessorArgumentsType'
       // So we can access that data within...
       // PostProcessorArgumentsType is a structure containing (3) strings.
       PostProcessorArgumentsType args = (PostProcessorArgumentsType)postArgs;

       // Display the data passed in from the PST
       string msg = string.Format("\narg1={0}\narg2={1}\narg3={2}", args.Argument1, args.Argument2, args.Argument3);
       MessageBox.Show(msg, "NetHook Run", MessageBoxButtons.OK, MessageBoxIcon.Information);

       try
       {
           ret = true;  // Change to false to see differnet value pass "bacK' to the PST       
       }
       catch (Exception e)
       {
           Mastercam.IO.DialogManager.OK(e.ToString(), "Error while calling ReturnValueToPost");
           ret = false;
       }

       if (ret)
       {
           args.Argument1 = "30";                         
       }
       else
       {
           args.Argument1 = "50";            
       }
       // We can also 'set' using this property to send data back to the PST !
       PostingManager.PostProcessorArguments = args; // Update the values back to the PST
       return MCamReturn.NoErrors;
   }
}

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