protected override WriteFileResult WriteFile(string filename, int index, RhinoDoc doc, FileWriteOptions options) { bool binary = GlTFUtils.IsFileGltfBinary(filename); if (!UseSavedSettingsDontShowDialog) { ExportOptionsDialog optionsDlg = new ExportOptionsDialog(); optionsDlg.RestorePosition(); Eto.Forms.DialogResult result = optionsDlg.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow); if (result != Eto.Forms.DialogResult.Ok) { return(WriteFileResult.Cancel); } } glTFExportOptions exportOptions = glTFBinExporterPlugin.GetSavedOptions(); IEnumerable <Rhino.DocObjects.RhinoObject> objects = GetObjectsToExport(doc, options); if (!GlTFExporterCommand.DoExport(filename, exportOptions, binary, doc, objects, doc.RenderSettings.LinearWorkflow)) { return(WriteFileResult.Failure); } return(WriteFileResult.Success); }
private bool GetExportOptions(RunMode mode, out glTFExportOptions options) { if (mode == RunMode.Scripted) { options = new glTFExportOptions(); if (Rhino.Input.RhinoGet.GetBool("Compression", true, "None", "Draco", ref options.UseDracoCompression) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetBool("Export Materials", true, "No", "Yes", ref options.ExportMaterials) != Result.Success) { return(false); } if (options.ExportMaterials) { if (Rhino.Input.RhinoGet.GetBool("Use display color for objects with unset material", true, "No", "Yes", ref options.UseDisplayColorForUnsetMaterials) != Result.Success) { return(false); } } if (options.UseDracoCompression) { if (Rhino.Input.RhinoGet.GetInteger("Draco Compression Level (max=10)", true, ref options.DracoCompressionLevel, 1, 10) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetInteger("Quantization Position", true, ref options.DracoQuantizationBitsPosition, 8, 32) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetInteger("Quantization Normal", true, ref options.DracoQuantizationBitsNormal, 8, 32) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetInteger("Quantization Texture", true, ref options.DracoQuantizationBitsTexture, 8, 32) != Result.Success) { return(false); } } if (Rhino.Input.RhinoGet.GetBool("Map Rhino Z to glTF Y", true, "No", "Yes", ref options.MapRhinoZToGltfY) != Result.Success) { return(false); } return(true); } else { ExportOptionsDialog optionsDlg = new ExportOptionsDialog(); optionsDlg.RestorePosition(); Eto.Forms.DialogResult result = optionsDlg.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow); options = glTFBinExporterPlugin.GetSavedOptions(); return(result == Eto.Forms.DialogResult.Ok); } }