Guest

csharp and python-scripts-for-mastercam

Recommended Posts

Guest

McCSharp.dll Add-In -> A c# scripting extension for Mastercam. Merge the contents of the McCSharp folder with your Mastercam folder to install.

McCSharp.zip

Share this post


Link to post
Share on other sites
Guest

There was a missing file in the first .zip file.

McCSharp.dll Add-In -> A c# scripting extension for Mastercam. Merge the contents of the McCSharp folder with your Mastercam folder to install.

 

McCSharp.zip

 

Share this post


Link to post
Share on other sites
Guest
//C# script example
//OpenMastercamPartFolder.cs
//reference nethook_3
#r"C:/Program Files/Mcam2020/chooks/NETHook3_0.dll"
//get the current filename
var ret = System.IO.Directory.GetParent(Mastercam.IO.FileManager.CurrentFileName);
//write the current file name to mastercams event logger
Mastercam.IO.EventManager.LogEvent(Mastercam.IO.Types.MessageSeverityType.InformationalMessage,"",Mastercam.IO.FileManager.CurrentFileName);
//open the folder containing the current mastercam file in windows explorer
System.Diagnostics.Process.Start(ret.FullName);

 

Share this post


Link to post
Share on other sites
Guest
//C# script example
//VerifyOperationsByToolNumber.cs
//reference nethook_3
#r"C:/Program Files/Mcam2020/chooks/NETHook3_0.dll"
//get a list of the nethook supported lists in mastercam
var List = Mastercam.Support.SearchManager.GetOperations();
//loop through the list of operations
foreach(var operation in List)
{
//if the operation type is not nesting
if (operation.Type.ToString() != "Nesting")
     {
         //get the operations toolnumber
         var tlnum = operation.OperationTool.Number;
         //write the tool number to mastercams event logger
         Mastercam.IO.EventManager.LogEvent(Mastercam.IO.Types.MessageSeverityType.InformationalMessage,""," ToolNumber : " + tlnum.ToString());
         if(tlnum > 0 )
         {
         
         if(tlnum < 100)
         {
         //if the operations tool number is less than 100 set it unselected
         operation.SetSelectedState(false);
         }

         }

         if(tlnum > 100)
         {
         if(tlnum < 200)
         {
         //if the operations tool number is less than 200 and greater than 100 set it selected
         operation.SetSelectedState(true);
         }
         }
         if(tlnum < 300)
         {
         if(tlnum > 200)
         {
         //if the operations tool number is less than 300 and greater than 200 set it selected
         operation.SetSelectedState(false);
         }
         }
     }
}
//verify the selected operations
Mastercam.Support.ExternalAppsManager.RunFTCommand("OMverifySelectedOperations");

 

Share this post


Link to post
Share on other sites
Guest

Added some example scripts of calling functions from mastercams list of ft functions, New skinny user interface can be used as a sidebar to call functions while you program.

McCSharp.zip

Share this post


Link to post
Share on other sites
Guest

Please note you will have to manually set the path in your script file to the nethook3_0.dll file for your version of mastercam 

Share this post


Link to post
Share on other sites
Guest

It probably needs to be recompiled..

Let me check for those files

Share this post


Link to post
Share on other sites
Guest

 

CsScriptmenu.dll.zip

I compiled this aginst 2022 beta pb2, it should run on every Mastercam that has Nethook3_0.dll

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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