private void UpdateTextBoxesContent(IFCExportConfiguration config) { if (config != null) { textBoxSetupDescription.Text = config.FileVersionDescription; if (LastSelectedConfig.ContainsKey(config.Name)) { textBoxSetupCoordinateBase.Text = (new IFCSitePlacementAttributes(LastSelectedConfig[config.Name].SitePlacement)).ToString(); } else { textBoxSetupCoordinateBase.Text = (new IFCSitePlacementAttributes(config.SitePlacement)).ToString(); } } }
/// <summary> /// Exports as an IFC file on clicking OK. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">Event arguments that contains the event data.</param> private void buttonNext_Click(object sender, RoutedEventArgs args) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(textBoxSetupFileName.Text); string filePath = Path.GetDirectoryName(textBoxSetupFileName.Text); // Show Path is invalid message if the path is blank or invalid. if (!string.IsNullOrWhiteSpace(filePath) && !Directory.Exists(filePath)) { TaskDialog.Show("Error", Properties.Resources.ValidPathExists); } else { // Create a default .ifc file if the file name is blank if (String.IsNullOrWhiteSpace(filePath)) { updateFileName(); } // Check for a valid IFC File format, if it does not exists, append the default IFC file format to export to the file if (Path.GetExtension(textBoxSetupFileName.Text).IndexOf(Properties.Resources.IFC, StringComparison.CurrentCultureIgnoreCase) == -1) { textBoxSetupFileName.Text = textBoxSetupFileName.Text.ToString() + "." + m_defaultExt; } // Prompt for overwriting the file if it is already present in the directory. if (File.Exists(textBoxSetupFileName.Text)) { TaskDialogResult msgBoxResult = TaskDialog.Show(Properties.Resources.IFCExport, String.Format(Properties.Resources.FileExists, textBoxSetupFileName.Text), TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No); if (msgBoxResult == TaskDialogResult.No) { return; } } if (Win32API.RtlIsDosDeviceName_U(textBoxSetupFileName.Text) != 0) { TaskDialog.Show(Properties.Resources.IFCExport, String.Format(Properties.Resources.ReservedDeviceName, textBoxSetupFileName.Text)); return; } IFCExportConfiguration selectedConfig = GetSelectedConfiguration(); if (!EditConfigVisited && LastSelectedConfig.ContainsKey(selectedConfig.Name)) { selectedConfig = LastSelectedConfig[selectedConfig.Name]; } // This check will be done only for IFC4 and above as this only affects IfcMapConversion use that starts in IFC4 onward if (!OptionsUtil.ExportAsOlderThanIFC4(selectedConfig.IFCVersion)) { // Check whether the resulting offset (to wcs) will be too large due to geo-reference information, raise warning BasePoint surveyPoint = BasePoint.GetSurveyPoint(TheDocument); BasePoint projectBasePoint = BasePoint.GetProjectBasePoint(TheDocument); { XYZ deltaOffset = XYZ.Zero; switch (selectedConfig.SitePlacement) { case SiteTransformBasis.Internal: deltaOffset = projectBasePoint.Position; break; case SiteTransformBasis.Project: // Offset from Project point is Zero, unchanged from the initial value break; case SiteTransformBasis.Site: deltaOffset = projectBasePoint.Position - surveyPoint.Position; break; case SiteTransformBasis.Shared: deltaOffset = projectBasePoint.SharedPosition; break; default: break; } if (!XYZ.IsWithinLengthLimits(deltaOffset)) { TaskDialogResult msgBoxResult = TaskDialog.Show(Properties.Resources.IFCExport, Properties.Resources.OffsetDistanceTooLarge, TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel); if (msgBoxResult == TaskDialogResult.Cancel) { return; } } } } Result = IFCExportResult.ExportAndSaveSettings; Close(); // Set IFC File header with the selected exchange requirement if (selectedConfig.ExchangeRequirement != KnownERNames.NotDefined) { IFCFileHeader ifcFileHeader = new IFCFileHeader(); IFCFileHeaderItem fileHeaderItem; if (!ifcFileHeader.GetSavedFileHeader(IFCCommandOverrideApplication.TheDocument, out fileHeaderItem)) { // Do minimum initialization if the header item is not initialized fileHeaderItem = new IFCFileHeaderItem(IFCCommandOverrideApplication.TheDocument); } string erName = selectedConfig.ExchangeRequirement.ToString(); fileHeaderItem.FileDescription = "ExchangeRequirement [" + erName + "]"; ifcFileHeader.UpdateFileHeader(IFCCommandOverrideApplication.TheDocument, fileHeaderItem); } LastSelectedConfig[selectedConfig.Name] = selectedConfig; TheDocument.Application.WriteJournalComment("Dialog Closed", true); } }