/// <summary> /// Save active Revit document as STL file according to customer's settings. /// </summary> /// <param name="fileName">The name of the STL file to be saved.</param> /// <param name="settings">Settings for save operation.</param> /// <returns>Successful or failed.</returns> public GeneratorStatus SaveSTLFile(string fileName, Settings settings) { m_Settings = settings; try { m_StlExportCancel.Show(); // save data in certain STL file if (SaveFormat.Binary == settings.SaveFormat) { m_Writer = new SaveDataAsBinary(fileName, settings.SaveFormat); } else { m_Writer = new SaveDataAsAscII(fileName, settings.SaveFormat); } m_Writer.CreateFile(); ScanElement(settings.ExportRange); System.Windows.Forms.Application.DoEvents(); if (m_StlExportCancel.CancelProcess == true) { m_StlExportCancel.Close(); return(GeneratorStatus.CANCEL); } if (0 == m_TriangularNumber) { MessageBox.Show(STLExportResource.ERR_NOSOLID, STLExportResource.MESSAGE_BOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_StlExportCancel.Close(); return(GeneratorStatus.FAILURE); } if (SaveFormat.Binary == settings.SaveFormat) { // add triangular number to STL file m_Writer.TriangularNumber = m_TriangularNumber; m_Writer.AddTriangularNumberSection(); } m_Writer.CloseFile(); } catch (SecurityException) { MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_StlExportCancel.Close(); return(GeneratorStatus.FAILURE); } catch (Exception) { MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_StlExportCancel.Close(); return(GeneratorStatus.FAILURE); } m_StlExportCancel.Close(); return(GeneratorStatus.SUCCESS); }
/// <summary> /// Save active Revit document as STL file according to customer's settings. /// </summary> /// <param name="fileName">The name of the STL file to be saved.</param> /// <param name="settings">Settings for save operation.</param> /// <returns>Successful or failed.</returns> public GeneratorStatus SaveSTLFile(string fileName, Settings settings) { m_Settings = settings; try { m_StlExportCancel.Show(); // save data in certain STL file if (SaveFormat.Binary == settings.SaveFormat) { m_Writer = new SaveDataAsBinary(fileName, settings.SaveFormat); } else { m_Writer = new SaveDataAsAscII(fileName, settings.SaveFormat); } m_Writer.CreateFile(); ScanElement(settings.ExportRange); System.Windows.Forms.Application.DoEvents(); if (m_StlExportCancel.CancelProcess == true) { m_StlExportCancel.Close(); return GeneratorStatus.CANCEL; } if (0 == m_TriangularNumber) { MessageBox.Show(STLExportResource.ERR_NOSOLID, STLExportResource.MESSAGE_BOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_StlExportCancel.Close(); return GeneratorStatus.FAILURE; } if (SaveFormat.Binary == settings.SaveFormat) { // add triangular number to STL file m_Writer.TriangularNumber = m_TriangularNumber; m_Writer.AddTriangularNumberSection(); } m_Writer.CloseFile(); } catch (SecurityException) { MessageBox.Show(STLExportResource.ERR_SECURITY_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_StlExportCancel.Close(); return GeneratorStatus.FAILURE; } catch (Exception) { MessageBox.Show(STLExportResource.ERR_EXCEPTION, STLExportResource.MESSAGE_BOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_StlExportCancel.Close(); return GeneratorStatus.FAILURE; } m_StlExportCancel.Close(); return GeneratorStatus.SUCCESS; }