Last preload tool

Last preload tool

sevenfive85
Advocate Advocate
751 Views
2 Replies
Message 1 of 3

Last preload tool

sevenfive85
Advocate
Advocate

Can someone please help me with the codes below? I want the last preload tool to always be T99.  Thank you

 

 

 

 

   if (insertToolCall) {
     if (!machineConfiguration.isHeadConfiguration()) {
     var nextTool = getNextTool(tool.number);
       if (nextTool) { // is there a next tool after this
         writeBlock(gMotionModal.format(0), gFormat.format(currentSection.isMultiAxis() ? 43.5 : 43), zOutput.format(initialPosition.z),
         hFormat.format(lengthOffset), setCoolant(tool.coolant), ("T" + toolFormat.format(nextTool.number)));
          // set coolant after we have positioned at Z
          // setCoolant(tool.coolant);
        } else {  // no next tool
        var section = getSection(0);
        var firstToolNumber = section.getTool().number;
        if (tool.number != firstToolNumber) {
       writeBlock(gMotionModal.format(0), gFormat.format(currentSection.isMultiAxis() ? 43.5 : 43), zOutput.format(initialPosition.z),
          hFormat.format(lengthOffset), setCoolant(tool.coolant), ("T" + toolFormat.format(firstToolNumber)));
        } else {   //added if user selected only one operation
    writeBlock(gMotionModal.format(0), gFormat.format(currentSection.isMultiAxis() ? 43.5 : 43), zOutput.format(initialPosition.z),
          hFormat.format(lengthOffset), setCoolant(tool.coolant), ("T" + toolFormat.format(tool.number)));
  }
      }
     } else {

0 Likes
Accepted solutions (1)
752 Views
2 Replies
Replies (2)
Message 2 of 3

GeorgeRoberts
Autodesk
Autodesk
Accepted solution

Hello,

 

Thanks for posting. Based on the code you supplied, you could just check to see if there is no next tool, then select T99 with something like this:

 

        var nextTool = getNextTool(tool.number);
        if (!nextTool) {
          nextTool = 99;
        }

But you might want to add more checks, perhaps to ensure it is the final section as well (although I can't think of a reason nextTool wouldn't have a value if it wasn't the last section):

 

 

        var nextTool = getNextTool(tool.number);
        if (!hasNextSection() && !nextTool) {
          nextTool = 99;
        }

 

Hope this helps!

 

 

 

 

-

George Roberts

Manufacturing Product manager
If you'd like to provide feedback and discuss how you would like things to be in the future, Email Me and we can arrange a virtual meeting!
Message 3 of 3

sevenfive85
Advocate
Advocate

Thank you George!!

0 Likes