N Sequence number to match tool number

N Sequence number to match tool number

macr72515SL4L
Contributor Contributor
543 Views
6 Replies
Message 1 of 7

N Sequence number to match tool number

macr72515SL4L
Contributor
Contributor

Hi all,

 

Can someone please assist me on PP so that the N sequence number matches the tool number
and increments every time the tool is being called.

 

Example:

N0101
T1 M6
;
;
N1201
T12 M6
;
;
N0102
T1 M6
;
;
N1202
T12 M6
;
;


Thanks

0 Likes
Accepted solutions (3)
544 Views
6 Replies
Replies (6)
Message 2 of 7

da_fish
Advocate
Advocate
Accepted solution

This will do what you are looking for:

function writeCommentSeqno(text) {
  if (toolSequenceNumbers[tool.number] != undefined) {
    toolSequenceNumbers[tool.number]++;
  } else {
    toolSequenceNumbers[tool.number] = 1;
  }
  writeln(("N" + ((tool.number * 100) + toolSequenceNumbers[tool.number])) + " " + formatComment(text));
}

Some where in the beginning of your post you'll have to declare the variable:

var toolSequenceNumbers = {};

 

If you replace your writeCommentSeqno() function with the code it should work just fine. If you need more help integrating this logic into your post let me know.

 

0 Likes
Message 3 of 7

macr72515SL4L
Contributor
Contributor

Thanks @da_fish! That worked really well on my post for Okuma mill but can't make it work on the Makino posts. 

Somehow the Makino post has different N sequencing format.

0 Likes
Message 4 of 7

da_fish
Advocate
Advocate

You're welcome I'm glad it worked!

 

I looked at a Makino post that I got off the library and it certainly has a different code format for outputting sequence numbers. I'll be away from my desk most of the day tomorrow so I'll look into it more and try to get back to you later tomorrow are the next day.

0 Likes
Message 5 of 7

macr72515SL4L
Contributor
Contributor
Thanks! will be much appreciated. ; )
0 Likes
Message 6 of 7

da_fish
Advocate
Advocate
Accepted solution

@macr72515SL4L, Find the writeToolBlock() function which should look like this:

 

function writeToolBlock() {
  var show = getProperty("showSequenceNumbers");
  setProperty("showSequenceNumbers", (show == "true" || show == "toolChange") ? "true" : "false");
  writeBlock(arguments);
  setProperty("showSequenceNumbers", show);
}

 

And replace it with the following code:

 

function writeToolBlock() {
  var num;
  if (getProperty("showSequenceNumbers") == "toolChange") {
    if (toolSequenceNumbers[tool.number] != undefined) {
      toolSequenceNumbers[tool.number]++;
    } else {
      toolSequenceNumbers[tool.number] = 1;
    }
    num = "N" + ((tool.number * 100) + toolSequenceNumbers[tool.number])
  }
  writeBlock(num, arguments);
}

 

 And don't forget to declare the variable somewhere towards the beginning of your post:

var toolSequenceNumbers = {};

 

If the Show Sequence Numbers property is set to "Only on tool change" then it will output the special N numbers, otherwise it will post normally.

 

I hope this works for you!

0 Likes
Message 7 of 7

macr72515SL4L
Contributor
Contributor
Accepted solution

Thanks @da_fish! It's working well. Appreciate your help.  👍

0 Likes