Solon Aquila
New Member
- Joined
- Sep 24, 2011
- Messages
- 33
Where I work, I take large remnants of raw material and see if I can cut them down to smaller pieces so we have less waste. I've created a few spreadsheets that allow me to do this a bit more efficiently.
Once I've decided which piece to cut, the meat of the operation lies in being able to get the most pieces from the original block.
It took me a bit to work out but I have a spreadsheet that looks at all possible cutting combinations (how I did it is a separate tab).
The attached image (sorry, I can't get xl2bb to load) shows 6 source to work piece combinations.
Each uses formulas to determine the number of pieces yielded by that combination.
In case multiple combinations yield the same number of pieces, I use 'which leaves the largest individual piece of leftover' as the decider. That's not AS critical, but it gives more options for getting another part from the leftover.
I'm trying to figure out how to write a script that will look at the source piece and work piece dimensions and work out which combination gives the best yield / leftover combination.
I think I can set up variables for each dimension and use that spreadsheet as a basis for figuring out how to do the calculations.
•
So, if I take a look at the formulas I used in the spreadsheet, can I basically assign variables to the results of each calculation, then compare each result variable to determine which is best.
Kind of (currently ignoring largest leftover piece):
Sl= source length cell Pl= piece length cell RA=Result A RC=Result C RF=Result F
Sw=source width cell Pw= piece width cell RB=Result B RD=Result D
Sh=source height cell Ph= piece height cell RC=Result C RE=Result E
(Sl÷Pl) × (Sw÷Pw) × (Sh÷Ph)= RA
(Sl÷Ph) × (Sw÷Pl) × (Sh÷Pw)= RB
(Sl÷Pw) × (Sw÷Ph) × (Sh÷Pl)= RC
(Sl÷Pl) × (Sw÷Ph) × (Sh÷Pw)= RD
(Sl÷Pw) × (Sw÷Pl) × (Sh÷Ph)= RE
(Sl÷Ph) × (Sw÷Pw) × (Sh÷Pl)= RF
In a standard spreadsheet, I would go to the bottom of the results column and say "MAX(RA, RB, RC, RD, RE, RF, RG)" but I don't know how to do that in a script.
So, if it looks like the 'code' above appears to be a workable way to test all of the options, how the heck do I say "pick the max of these" in a script?
TIA
Once I've decided which piece to cut, the meat of the operation lies in being able to get the most pieces from the original block.
It took me a bit to work out but I have a spreadsheet that looks at all possible cutting combinations (how I did it is a separate tab).
The attached image (sorry, I can't get xl2bb to load) shows 6 source to work piece combinations.
Each uses formulas to determine the number of pieces yielded by that combination.
In case multiple combinations yield the same number of pieces, I use 'which leaves the largest individual piece of leftover' as the decider. That's not AS critical, but it gives more options for getting another part from the leftover.
I'm trying to figure out how to write a script that will look at the source piece and work piece dimensions and work out which combination gives the best yield / leftover combination.
I think I can set up variables for each dimension and use that spreadsheet as a basis for figuring out how to do the calculations.
•
So, if I take a look at the formulas I used in the spreadsheet, can I basically assign variables to the results of each calculation, then compare each result variable to determine which is best.
Kind of (currently ignoring largest leftover piece):
Sl= source length cell Pl= piece length cell RA=Result A RC=Result C RF=Result F
Sw=source width cell Pw= piece width cell RB=Result B RD=Result D
Sh=source height cell Ph= piece height cell RC=Result C RE=Result E
(Sl÷Pl) × (Sw÷Pw) × (Sh÷Ph)= RA
(Sl÷Ph) × (Sw÷Pl) × (Sh÷Pw)= RB
(Sl÷Pw) × (Sw÷Ph) × (Sh÷Pl)= RC
(Sl÷Pl) × (Sw÷Ph) × (Sh÷Pw)= RD
(Sl÷Pw) × (Sw÷Pl) × (Sh÷Ph)= RE
(Sl÷Ph) × (Sw÷Pw) × (Sh÷Pl)= RF
In a standard spreadsheet, I would go to the bottom of the results column and say "MAX(RA, RB, RC, RD, RE, RF, RG)" but I don't know how to do that in a script.
So, if it looks like the 'code' above appears to be a workable way to test all of the options, how the heck do I say "pick the max of these" in a script?
TIA