This paper proposes a new algorithm for the automatic generation of toolpaths for machining complex geometric positions, such as molds used in orthosis production. The production of individualized orthoses often requires the use of multi-axis machining systems, such as five-axis machines or industrial robots. Typically, complex and expensive CAD/CAM systems are used to generate toolpaths for these machines, requiring the definition of a machining strategy for each surface. While this approach can achieve a reliable and high-quality machining process, it is very time-consuming and makes it challenging to meet the criteria for rapid production of orthopedic aids. Given that their production is a custom-made process using individual shapes as inputs, the toolpath generation process becomes even more demanding. To address these challenges, this paper proposes an algorithm suitable for the automatic generation of toolpaths for such complex positions. The proposed algorithm has been tested and has proven to be robust and applicable.