Beam length cut optimization

Hi, i am trying to determine how many standard length beams i need to buy in order to have minimal waste residue. I am fairly new to dynamo so I only have the starting phase of this project and an idea on how to create the rest but I don’t know how to actually do that.

I introduced all the beams I need. I now need to create a new list that takes the first element and combines it with another element from that list and so on until the sum is equal or less than the standard cut length, then the same for algorithm for the next element. The items must not be repeated.

So is there a way to do that?
Thank you,

Wrong binding in the first picture

A list of basic nodes to use for this task can be found here along with their description:
This will let you start elaborating on your concept

@r.anghelus Basically, the total length of the individual beams divided by the standard length should give you the number of standard lengths, right?

If I’ve correctly understood your intent, below is a graph somewhat similar to yours that does the needful


Thanks. It’s helpful.

Thank you for your reply, but that’s not what I a after. I can do that math inside Revit.
What I want to do is determine how many individual beams I can cut from standard length beams with minimum wastage.

As you can determine from the following example: Let’s say I need to cut 10 beams at 90 un and the standard lenght is 100 un. The math you provided will result in 900 un - 9 standard beams, but if do so then the 10th beam will be composed from individual residues of 10un each.

Just a question: is the standard length at 500 and the lengths you need at 300, 400 and 320 as shown in the picture, or is it other values in reality?

They are test values. I want to create my own way of designing timber roof frames (in seismic areas) and I also want to control cost. I will attach a picture. Sorry but the naming is Romanian.

(The pink yes/no values are if the beam needs additional joints and how many are numbered in the next column. Also, I have scheduled the waste material.)

Is there something wrong with dedicated softwares/add-ins?

Thank you for the links. I’ve used the first add-in, but I want a compact file instead of having files scattered around the computer. I have also created special sheets to export all required text and legal forms form Revit to pdf.

There is no straight forward answer to this. You’ll need some form of recursion and optimization techniques. I’m thinking Optimo could be used to good affect here but that’s beyond me currently.

You can make it somewhat easier, and sacrifice some optimization, if you first order the lists by length. Then start with the longest and check if the longest added to the next longest fits in one stock length. If it does, see if adding the third does as well, etc. If the second length doesn’t work, add the first to the third, and continue on from there. If adding each element to the list singularly to the first are all too long for the stock length then the first piece is the only one that will fit. Then set the first length, and whatever lengths could be added to it, aside and start the whole process over with the next item on the list.

You don’t technically need to sort the list first but I believe it makes it slightly faster. You could also, with the list sorted, work from both ends – compare 1st and last, etc.


That should get you the shortest standard length beam for each beam (assuming your list of standard lengths is sorted correctly).

If you’re after minimizing cost by buying larger beams and cutting them in half, the problem does in face become more difficult due to a dozen factors (love, shipping, region, availability, number of cuts, workability of larger members, etc).

1 Like

If all the beams are approximately the same length, this should work pretty well. I would probably add in a calculation of the standard deviation of the beam sizes around this shortest standard to see how it did. Possibly add in another version of the ShortestStandard that deals with any beams outside of whatever SD seemed appropriate. Or take those lengths outside the SD and run an optimization for multiple cuts on a standard length to get the best of both worlds.

Sounds like the bin packing algorithm. Have a look at the below video, it should give you a good idea on how to implement this in Dynamo:


First-fit decreasing was what I was trying to explain earlier… he explains it better!


Here’s a solution for the First Fit Decreasing method. You can find the custom node in my latest BIM4Struc.Productivity (version 1.3.3) package.


@Dieter_Vermeulen is there any way to have multiple stock lengths? Seems like this would allow even better tightening of the optimization