public static void Export(Ai.Scene aiScene, string fileName, Ai.PostProcessSteps postProcessSteps = Ai.PostProcessSteps.None) { var aiContext = new Ai.AssimpContext(); var formatExtension = Path.GetExtension(fileName).Substring(1); var formatId = aiContext.GetSupportedExportFormats() .First(x => x.FileExtension.Equals(formatExtension, StringComparison.OrdinalIgnoreCase)).FormatId; aiContext.ExportFile(aiScene, fileName, formatId, postProcessSteps); }
public ExportDialog(MainWindow main) { _main = main; InitializeComponent(); using (var v = new AssimpContext()) { _formats = v.GetSupportedExportFormats(); foreach (var format in _formats) { comboBoxExportFormats.Items.Add(format.Description + " (" + format.FileExtension + ")"); } comboBoxExportFormats.SelectedIndex = ExportSettings.Default.ExportFormatIndex; comboBoxExportFormats.SelectedIndexChanged += (object s, EventArgs e) => { ExportSettings.Default.ExportFormatIndex = comboBoxExportFormats.SelectedIndex; UpdateFileName(true); }; } textBoxFileName.KeyPress += (object s, KeyPressEventArgs e) => { _changedText = true; }; // Respond to updates in the main window - the export dialog is non-modal and // always takes the currently selected file at the time the export button // is pressed. _main.SelectedTabChanged += (Tab tab) => { UpdateFileName(); UpdateCaption(); }; UpdateFileName(); UpdateCaption(); }
public ExportDialog(MainWindow main) { _main = main; InitializeComponent(); using (var v = new Assimp.AssimpContext()) { _formats = v.GetSupportedExportFormats(); foreach (var format in _formats) { comboBoxExportFormats.Items.Add(format.Description + " (" + format.FileExtension + ")"); } comboBoxExportFormats.SelectedIndex = ExportSettings.Default.ExportFormatIndex; comboBoxExportFormats.SelectedIndexChanged += (object s, EventArgs e) => { ExportSettings.Default.ExportFormatIndex = comboBoxExportFormats.SelectedIndex; UpdateFileName(true); }; } textBoxFileName.KeyPress += (object s, KeyPressEventArgs e) => { _changedText = true; }; // Respond to updates in the main window - the export dialog is non-modal and // always takes the currently selected file at the time the export button // is pressed. _main.SelectedTabChanged += (Tab tab) => { UpdateFileName(); UpdateCaption(); }; UpdateFileName(); UpdateCaption(); }
private void Export(object parameter) { FileExtension = FileExtension.ToString(); string exportedFile = FilePath + "\\" + FileName + '.' + FileExtension; if (FileExtension == "") { System.Windows.MessageBox.Show("Select a file extension"); return; } if (FileName == "") { System.Windows.MessageBox.Show("Choose a name for your file"); return; } if (!Directory.Exists(FilePath)) { System.Windows.MessageBox.Show("Path is invalid"); return; } if (File.Exists(exportedFile)) { System.Windows.MessageBox.Show("File already exists at " + FilePath); return; } else { bool result = false; if (Session.CurrentSession.HasCurrentProject() && Session.CurrentSession.CurrentProject.CurrentModel3D != null) scene = Session.CurrentSession.CurrentProject.CurrentModel3D.GetScene(); if (Scene == null) { System.Windows.MessageBox.Show("You must open a scene in order to export it"); return; } using (AssimpContext exporter = new AssimpContext()) { ExportFormatDescription[] exportFormat = exporter.GetSupportedExportFormats(); foreach (ExportFormatDescription format in exportFormat) { if (format.FileExtension == FileExtension) { result = exporter.ExportFile(scene, exportedFile, format.FormatId); break; } } if (result == false) { System.Windows.MessageBox.Show("Bad export file extension"); return; } } if (result == false) { System.Windows.MessageBox.Show("Export failed"); return; } Window currentWindow = parameter as Window; McWindow.CloseWindow(currentWindow); } }