- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In my current pp I'm creating a section in the header of my ncp files with some statistics about the movement during the processed jobs. It looks like this.
N95 ; | movement statistics
N100 ; | X: min=4101 max=337500
N105 ; | Y: min=4685 max=112693
N110 ; | Z: min=-500 max=12000
N115 ; | A: min=0.00 max=0.00
N120 ; | B: min=0.00 max=0.00
N100 ; | X: min=4101 max=337500
N105 ; | Y: min=4685 max=112693
N110 ; | Z: min=-500 max=12000
N115 ; | A: min=0.00 max=0.00
N120 ; | B: min=0.00 max=0.00
Previously I did the output at the end of the file, but now I found that I can use DeferredVariables to move this section to the header of my output file. Unfortunately DeferredVariables doesn't accept strings or objects.
My solution now is the following:
...
stats = [statX,statY,statZ,statA,statB];
statFormat = createFormat({});
statFormat.format = function(idx){ return stats[idx].toString(); }
...
function onOpen(){
...
writeComment(DeferredVariables.get("statX",statFormat));
...
writeComment(DeferredVariables.get("statA",statFormat));
}
function onClose() {
...
DeferredVariables.set("statX",stats.indexOf(statX));
...
DeferredVariables.set("statB",stats.indexOf(statB));
...
}
where statX,... are objectes with an update method that is called in the onchange callback of the according output variable and a toString method which outputs a string i.e Y: min=-124930 max=-105630.
Are there any Doubts about this solution? If not it might help others to use strings or objects in DeferredVariables.
Thanks in advance
Solved! Go to Solution.
Link copied