First is the math, but just as import is allowing for defects both natural and man made. You must also remember the losses due to the machining of the parts. (Blade and or bit kerf etc)
Depending on the quality of the rough lumber I use at least 20% more up to double what the math tells you. I harvest , mill and dry my own lumber. When folks come to purchase rough lumber some bring cardboard cut outs to help themselves to choose the boards they need.
You can learn to calculate by board feet and that may help.
The calculation is LxWxH (in inches) divided by 144
For instance, your shelves are 1.5"x18"x20"each
1.5x18x20=540…540/144= 3.75 board feet (bf)
So for two shelves, you would need 7.5bf (3.75x2)
A 1.5 (aka 6/4 thick board at the lumber store) that is 8" wide and 10ft long would measure as such:
You need 7.5bf, add at least 20% for waste/defects/cut patterns, and get at least that much in board feet of wood. It’s better to get too much! You can always use it for other things if you have leftovers.
You can probably find a board foot calculator app to help you but if you learn how to do it, all you’ll ever need is a calculator.
Try downloading DeepNest, simple to use with a good amount of nesting features. You can import SVG, DXF or create custom-sized rectangles via an input box. It’s free and open-source which is an added bonus. Even if you don’t use the exported DXF it’s handy to generate the optimum nest. There is also a web-based version of the same program here. I use it all the time for laser cutting.
My solution for this is using a combination of a simple spreadsheet along with Opticutter.
When I am at the lumber yard, I will measure the width and length they have available and enter some data into the spreadsheet to calculate the number of boards needed, then I use OptiCutter to map against what they have in stock to minimize waste. Fortunately the yard is friendly and will allow me to layout and mark the boards to make sure everything is correct.
Between the two of them I can reduce the amount of waste on a project. Especially important when doing projects with expensive wood, like Walnut.
I have both on my tablet and so far it works.
I would prefer to have an app that I could enter the finished sizes I want against what is in stock and help optimize the number of boards needed. I thought of developing something (and might) with the real challenge being the optimizing code. That is a fairly complex bit of logic that I’m not 100% sure on how to implement. Or I continue doing with a spreadsheet and Opticutter.