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:

Edit Posting Details


Recommended Posts

Howdy everyone,

 

Is there any way to tell the post processor to post all operations to a specific file name? I know I can set the file path like this:

Mastercam.Operations.OperationsManager.PostAllOperations(string filePath);

But I'm looking more for:

Mastercam.Operations.OperationsManager.PostAllOperations(string 
filePath + filename.Extension);

 

 

Link to comment
Share on other sites

Below is a snippet of code from a function, it shows how to set the nci name 

 internal static void CreateNci(Part part, string outputFolder)
        {
            OperationsManager.SelectAllOperations();
            var opsToPost = SearchManager.GetOperations(true);
            var nciFileName = part.PrimaryMastercamDrawingFilePath.ToLower().Replace("." + Globals.ExtMcx, "." + Globals.ExtNci);

            // Set the job setup stock per User Story B-31592
            OperationsManager.JobSetupStockSize = new Point3D(part.Panel.X, part.Panel.Y, part.Panel.Z);

            FileManager.Save();

            foreach (var t in opsToPost)
            {
                t.NCIName = nciFileName;
                t.Commit();
            }

            OperationsManager.PostOperations(opsToPost, outputFolder, false, true, false);

            // Some operations will be marked dirty for whatever reason, so just regen them
            foreach (var t in opsToPost)
            {
                t.Regenerate();
            }
        }
Link to comment
Share on other sites

Quite similar to Mick's, this is the function I wrote and use in my current project.

 

Also, I have multi-threading disabled in Mastercam for toolpath generation. This is to ensure all regeneration is complete before posting.

(See here for more info)

public static bool regenAndPost(string fileName, bool onlySelected){
            string pathNCI = System.IO.Path.ChangeExtension(fileName,".nci");

            Mastercam.Database.Operation[] allOps = Mastercam.Support.SearchManager.GetOperations(onlySelected);

            foreach (var op in allOps)
            {
                op.NCIName = pathNCI;
                op.Commit(false);
                if (op.Dirty)
                {
                    op.Regenerate();
                }
            }

            foreach (var op in allOps)
            {
                op.Retrieve();
                if (op.Dirty)
                {
                    System.Windows.Forms.MessageBox.Show("Error - dirty operation. Try again.");
                    return false;
                }
            }

            Mastercam.Operations.OperationsManager.PostAllOperations(System.IO.Path.GetDirectoryName(pathNCI), true); 
            Mastercam.Operations.OperationsManager.RefreshOperationsManager();
            return true;
        }
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...