Skip to content

Commit 80b0502

Browse files
committed
Material utilisation
closes #98, #33, 31
1 parent e7f8cd4 commit 80b0502

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

main/background.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,8 +1745,10 @@ function placeParts(sheets, parts, config, nestindex) {
17451745

17461746
console.log('WATCH', allplacements);
17471747

1748+
const utilisation = totalsheetarea > 0 ? (area / totalsheetarea) * 100 : 0;
1749+
console.log(`Utilisation of the sheet(s): ${utilisation.toFixed(2)}%`);
17481750

1749-
return { placements: allplacements, fitness: fitness, area: sheetarea,totalarea: totalsheetarea, mergedLength: totalMerged };
1751+
return { placements: allplacements, fitness: fitness, area: sheetarea,totalarea: totalsheetarea, mergedLength: totalMerged, utilisation: utilisation};
17501752
}
17511753

17521754
// New helper function to analyze sheet holes

main/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<div id="nestinfo" class='{{ nests.length > 0 ? "active" : "" }}'>
6464
<div class="group"><h1>{{ getSelected().length > 0 ? getSelected()[0].placements.length : '-' }}</h1><span class="label">{{ getSelected().length > 0 ? (getSelected()[0].placements.length > 1 ? 'sheets used' : 'sheet used') : '' }}</span></div>
6565
<div class="group"><h1>{{ getPartsPlaced() }}</h1><span class="label">parts placed</span></div>
66+
<div class="group"><h1>{{ getUtilisation() }}%</h1><span class="label">sheet utilisation</span></div>
6667
<div class="group"><h1>{{ getTimeSaved() }}</h1><span class="label">laser time saved</span></div>
6768
<div class="group"><h1>best nests so far</h1></div>
6869
<div id="nestlist">

main/page.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,11 @@ ready(async function () {
16601660

16611661
return num + '/' + total;
16621662
},
1663+
getUtilisation: function () {
1664+
const selected = this.get('getSelected')(); // reuse getSelected()
1665+
if (selected.length === 0) return '-';
1666+
return selected[0].utilisation.toFixed(2); // Formata para 2 decimais
1667+
},
16631668
getTimeSaved: function () {
16641669
var ne = this.get('nests');
16651670
var selected = ne.filter(function (n) {

0 commit comments

Comments
 (0)