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