public void SliceHalfExecuted() { MainViewModel.IsBusy = true; var sourceFile = DataModel.SourceVoxelFilepath ?? DataModel.VoxelFilepath; var asteroid = new MyVoxelMap(); asteroid.Load(sourceFile); asteroid.RefreshAssets(); var height = asteroid.BoundingContent.Size.Y + 1; // remove the Top half. asteroid.RemoveMaterial(null, null, (int)Math.Round(asteroid.ContentCenter.Y, 0), asteroid.Size.Y, null, null); var tempfilename = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension); asteroid.Save(tempfilename); var newFilename = MainViewModel.CreateUniqueVoxelStorageName(DataModel.Name); var posOrient = DataModel.PositionAndOrientation.HasValue ? DataModel.PositionAndOrientation.Value : new MyPositionAndOrientation(); posOrient.Position.y += height; // genreate a new Asteroid entry. var newEntity = new MyObjectBuilder_VoxelMap { EntityId = SpaceEngineersApi.GenerateEntityId(IDType.ASTEROID), PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene, StorageName = Path.GetFileNameWithoutExtension(newFilename), PositionAndOrientation = new MyPositionAndOrientation { Position = posOrient.Position, Forward = posOrient.Forward, Up = posOrient.Up } }; var structure = MainViewModel.AddEntity(newEntity); ((StructureVoxelModel)structure).UpdateNewSource(asteroid, tempfilename); // Set the temporary file location of the Source Voxel, as it hasn't been written yet. MainViewModel.IsModified = true; MainViewModel.IsBusy = false; }