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:

csharp and python-scripts-for-mastercam


Guest
 Share

Recommended Posts

//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);

 

Link to comment
Share on other sites
//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");

 

Link to comment
Share on other sites
  • gcode unpinned this topic
  • 6 months later...
  • gcode pinned this topic
  • 3 months later...
  • 4 weeks later...
  • 2 weeks later...
  • ihsDavidM unpinned this topic
  • 3 months later...
  • 1 year later...

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