We introduce a lattice model able to describe damage and yielding in heterogeneous materials ranging from brittle to ductile ones. Ductile fracture surfaces, obtained when the system breaks once the strain is completely localized, are shown to correspond to minimum energy surfaces. The similarity of the resulting fracture paths to the limits of brittle fracture or minimum energy surfaces is quantified. The model exhibits a smooth transition from brittleness to ductility. The dynamics of yielding exhibits avalanches with a power-law distribution.