public void ReplaceSelectedExecuted(string materialName) { MainViewModel.IsBusy = true; var sourceFile = DataModel.SourceVoxelFilepath ?? DataModel.VoxelFilepath; var asteroid = new MyVoxelMap(); asteroid.Load(sourceFile, SpaceEngineersCore.Resources.GetDefaultMaterialName(), true); if (string.IsNullOrEmpty(materialName)) { asteroid.RemoveContent(SelectedMaterialAsset.MaterialName, null); DataModel.VoxCells = asteroid.SumVoxelCells(); } else { asteroid.ReplaceMaterial(SelectedMaterialAsset.MaterialName, materialName); } var tempfilename = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension); asteroid.Save(tempfilename); DataModel.SourceVoxelFilepath = tempfilename; MainViewModel.IsModified = true; MainViewModel.IsBusy = false; DataModel.UpdateGeneralFromEntityBase(); DataModel.MaterialAssets = null; DataModel.InitializeAsync(); }