BH Davis

BH Davis

  • NA
  • 204
  • 345

Need help setting up an input box.

Jul 27 2024 4:47 PM

I'm running a CAM software package that uses C# macro coding to activate tasks.

I need to create a macro that will rename a tool loaded in my spindle. For example, if I had Tool #1 (T1) in the spindle when I shut the machine down, but the CAM software says I don't have a tool loaded on restart, I'd want to change the stated T0 on screen to T1. I'd like to press the button on my UCCNC screen and have it ask me what tool number I want to use for the renaming.

I have the following code someone generously created for me that generates the input box. However this is for a tool change, and not a tool renaming.

string val = exec.TextQuestion("Enter loaded tool number.");
string toolch = "M6 T" + val;
exec.Code(toolch);

which executes a tool change.

Here is C# code where I can manually enter T61 T(#) in the manual input line in UCCNC and specify T1 to get the loaded tool renamed to T1. This works fine but I'd like to attach this to a macro so I only have to push a screen button and then enter the tool number.

int newTool = exec.Getnewtool();
if (newTool < 0)
{
return;
}
else
{
exec.Setcurrenttool(newTool);
}

I've tried combing the two command sequences in numerous ways similar to what I've pasted below. None have worked though. All have given me a code error message in UCCNC.

string val = exec.TextQuestion("Enter loaded tool number.");
string Setcurrenttool(newTool); = "M61 T" + val;
exec.Setcurrenttool(newTool);

Could someone help me out here?

Thanks,
BH


Answers (1)