Measurements of charmed-meson production in interactions between 350 GeV/c π− particles and nuclei