The generation of optimal NC code to drive milling machines for models defined by freeform trimmed surfaces is a difficult problem. In practice, two main approaches are used to generate toolpaths for surfaces, neither of which is optimal, in general. The first exploits the parametric representation, and generates isocurves that are uniformly distributed across the parametric domain. This approach is not optimal if the surface mapping into Euclidean space is not isometric. The second approach contours the models by intersecting the surfaces with planes equally spaced in Euclidean space, resulting in a piecewise-linear toolpath approximation which is nonadaptive to the local surface geometry. Further, the toolpath generated by contouring is suitable for 3-axis milling, but is inappropriate for 5-axis milling. In the paper, an algorithm developed to extract isocurves for rendering adaptively is modified and enhanced to generate milling toolpaths for models consisting of trimmed surfaces, and it can be used in both -3 and 5-axis milling. The resulting toolpaths do not gouge locally, and they combine the advantages of both prior approaches. The output toolpath is appealing, since it is composed of isoparametric curves, and is therefore compact, exact, and easy to process. Further, it is more optimal than the previous methods in that the resulting toolpath is shorter, and it provides a direct quantitative bound on the resulting scallop height. This algorithm has been used to compute gouge-avoiding toolpaths for the automatic milling of freeform surfaces, without the introduction of auxiliary check and drive surfaces being required.