Zaffin_D

Verified Members
  • Content count

    311
  • Joined

  • Last visited

Community Reputation

177 Excellent

3 Followers

About Zaffin_D

  • Rank
    Advanced Member

Recent Profile Visitors

1,202 profile views
  1. Zaffin_D

    Code expert Sync code setting for Multi Stream Nc code.

    I recommend looking online for some resources about regular expressions. It’s a vast topic, and it’s not one I’m qualified to cover; but I’ll do my best to break down the key parts of the regex. Starting off we have a word boundary \b. Next we match ‘M’ literally. The open and closing parentheses define a match group. The numbers between the braces define a range of values to match. So [1-9] will match 1, 2, 3, 4, 5, 6, 7, 8, or 9. The pipe ‘|’ means or, and with the two other patterns we can range check from 101-999. Again, I really recommend Googling regular expressions; you’ll find tons of resources.
  2. Zaffin_D

    Code expert Sync code setting for Multi Stream Nc code.

    Can you provide a screen shot of what you entered in the text box? It's working for me, see below.
  3. Zaffin_D

    Code expert Sync code setting for Multi Stream Nc code.

    The above regex has some holes in it. Here is a better one... \bM([1-9][0-9][1-9]|[1-9][1-9][0-9]|[2-9][0-9][0-9])\b ...and here is the regex being tested against some common M-codes.
  4. Zaffin_D

    Code expert Sync code setting for Multi Stream Nc code.

    Give the below regex a try. \bM([1-9][0-9][1-9]|[2-9][0-9][0-9])\b
  5. Correct(ish) you can have as many stacks as you'd like, but they exist in memory. If you want to write them to disk you must use the pop function with mode -1 Or you could use a different file stream to write the data to disk, but it's not as automatic. You should contact CNC's post department. Sort of, here is a Knowledgebase article that shows how to reuse a buffer, but as far as I'm aware you can't redefine it at runtime. Something can be done for sure, but without more detail it's hard to know what options to present.
  6. Use a stack? But, to write a stack to a file you need a buffer so it may not work for your application. I’m not sure why stacks aren’t used more often by post developers.
  7. This can happen when Mastercam is run as Administrator.
  8. The docs cover this pretty well, but here is an example of both methods being used. insert_cr_pnci20000 : 0 pnci20000$ if prmcode$ = 20104, [ insert_cr_pnci20000 = rparsngl(sparameter$, 4) ] insert_cr_opinfo : 0 lsof$ sparameter$ = opinfo(20104, 0) insert_cr_opinfo = rparsngl(sparameter$, 4) ~insert_cr_opinfo, e$ ~insert_cr_pnci20000, e$ #// Output -> #// insert_cr_opinfo .03125 #// insert_cr_pnci20000 .03125 On thing to note; pnci20000$ will not run if the pparameter$ postblock is present in the post.
  9. pnci20000$ is the preferred way to access the 20xxx and 30xxx range of parameters with the enhanced tool table. You can also use opinfo and parse the returned string, but that method isn’t quite as efficient.
  10. SlaveCam got it. You need to reset the main tool to the cloned assembly for the changes to stick. void OperationService::SetToolCoolant(int opID) { auto op = TpMainOpMgr.GetMainOpList().OpByID(opID); if (op != nullptr) { auto toolSystem = Cnc::Tool::GetToolSystem(); auto toolAssembly = Cnc::Tool::TlAssemblyCPtr(); if (toolSystem->Find(op->tl.slot, toolAssembly)) { auto toolAssemblyClone = toolAssembly->Clone(); if (toolAssemblyClone->HasMainTool()) { auto millTool = toolAssemblyClone->GetMillTool(); Cnc::Tool::TlCoolant tlCool; tlCool.SetFloodState(0); tlCool.SetFloodTime(1); tlCool.SetMistState(0); tlCool.SetMistTime(1); tlCool.SetToolState(0); tlCool.SetToolTime(1); millTool->SetCannedTxtCoolant(tlCool); toolAssemblyClone->SetMainTool(millTool); toolSystem->Update(toolAssemblyClone); } } } } The TlCoolant class is much more friendly than a vector. Sadly I knew about it less than a year ago; my memory isn't what it used to be. Makes me think that there has to be a friendlier way to update the operation coolant.
  11. Have you tested this? I had the below function for setting a tool's coolant, but no matter what I do the coolant won't stick. void OperationService::SetToolCoolant(int opID) { auto op = TpMainOpMgr.GetMainOpList().OpByID(opID); if (op != nullptr) { auto toolSystem = Cnc::Tool::GetToolSystem(); auto toolAssembly = Cnc::Tool::TlAssemblyCPtr(); if (toolSystem->Find(op->tl.slot, toolAssembly)) { if (toolAssembly->HasMainTool()) { auto millTool = toolAssembly->GetMillTool(); std::vector<short> cannedTextCoolant(20); cannedTextCoolant[0] = -3101; cannedTextCoolant[1] = -4103; cannedTextCoolant[2] = -5105; millTool->SetCannedTxtCoolant(cannedTextCoolant); toolSystem->Update(toolAssembly->Clone()); } } } } I'm also totally wrong about the right most digits. They do have something to do with on and off; new theory below. 01 and 02 sets ON and OFF for Coolant 1 03 and 04 sets ON and OFF for Coolant 2 ...skip a few... 19 and 20 sets ON and OFF for Coolant 10 So to set Coolant 5 to ON and Before, use -3109.
  12. Are you trying to modify the operation's coolant? If so, new style coolant is handled by canned text... void OperationService::SetOperationCoolant(int opID) { auto op = TpMainOpMgr.GetMainOpList().OpByID(opID); if (op != nullptr) { op->cantxt.cantxt[0] = -3101; op->cantxt.cantxt[1] = -4103; op->cantxt.cantxt[2] = -5105; DB_LIST_ENT_PTR dbPointer = nullptr; auto isSuccess = false; operation_manager( op, OPMGR_REWRITE, &dbPointer, &isSuccess); } } The values are a bit of a mystery to me but as far as I can tell... The left most digit will be a 3,4, or 5 corresponding to before, with, after The two right most digits are the coolant; 00 is coolant 1 off, 01 is coolant 1 on, 02 is coolant 2 off, 03 is coolant 2 on etc. For example, -5105 would mean coolant 3 on, after.
  13. Do some research into using property sheets; what you’re doing to set this up is unnecessary.
  14. Yes, you can pass a struct, see below File: OperationService.h #pragma once namespace OperationServiceNative { public value struct OperationData { System::String^ Comment; int ID; int Type; int ToolNumber; }; public ref class OperationService { public: OperationService(); OperationData^ GetOperationData(int opID); bool CreateOperation(OperationData% opData); ~OperationService(); }; } File: OperationService.cpp #include "pch.h" #include "OperationService.h" OperationServiceNative::OperationService::OperationService() { } OperationServiceNative::OperationData^ OperationServiceNative::OperationService::GetOperationData(int opID) { OperationData^ opData = nullptr; auto operation = TpMainOpMgr.GetMainOpList().OpByID(opID); if (operation != nullptr) { opData = gcnew OperationData(); System::String^ commentString = gcnew System::String(operation->comment); opData->Comment = commentString; opData->ID = operation->op_idn; opData->Type = operation->opcode; opData->ToolNumber = operation->tl.tlno; } return opData; } bool OperationServiceNative::OperationService::CreateOperation(OperationData% opData) { //Code to create an operation with the OperationData struct return false; } OperationServiceNative::OperationService::~OperationService() { } File: Main.cs namespace MyNetHook { using Mastercam.App; using Mastercam.App.Types; using OperationServiceNative; public class Main : NetHook3App { public override MCamReturn Run(int param) { var opService = new OperationService(); var opData = (OperationData)opService.GetOperationData(1); var newOpData = new OperationData() { Comment = "A new op", ID = 2, Type = 1, ToolNumber = 1 }; var isSuccess = opService.CreateOperation(ref opData); return MCamReturn.NoErrors; } } }

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