From bdfa9ff3f038bfbe18eda3b222f03a8b63387f2e Mon Sep 17 00:00:00 2001 From: HADM Date: Wed, 9 Mar 2022 15:02:39 +0100 Subject: [PATCH] Added ExportAllPhases option to export all elements regardless of phase --- .../IFCExportConfiguration.cs | 13 ++++++++---- .../IFCExportConfigurationsMap.cs | 6 ++++++ .../IFCExporterUIWindow.xaml | 1 + .../IFCExporterUIWindow.xaml.cs | 17 +++++++++++++-- .../Properties/Resources.Designer.cs | 9 ++++++++ .../Properties/Resources.de.resx | 3 +++ .../Properties/Resources.fr.resx | 3 +++ .../Properties/Resources.resx | 3 +++ .../Revit.IFC.Common/Revit.IFC.Common.csproj | 21 ++++++++++++++++++- .../Utility/ElementFilteringUtil.cs | 4 +++- .../Utility/ExportOptionsCache.cs | 13 ++++++++++++ 11 files changed, 85 insertions(+), 8 deletions(-) diff --git a/Source/IFCExporterUIOverride/IFCExportConfiguration.cs b/Source/IFCExporterUIOverride/IFCExportConfiguration.cs index 6741f2a4..3f894dc9 100644 --- a/Source/IFCExporterUIOverride/IFCExportConfiguration.cs +++ b/Source/IFCExporterUIOverride/IFCExportConfiguration.cs @@ -301,16 +301,21 @@ public KnownERNames ExchangeRequirement { /// public bool UseVisibleRevitNameAsEntityName { get; set; } = false; + /// + /// Value indicating whether to export all phases in the view or not + /// + public bool ExportAllPhases { get; set; } = false; + #endregion // AdvancedTab // Items under Entities to Export Tab #region EntitiesToExportTab - /// - /// Exclude filter string (element list in an arrary, seperated with semicolon ';') - /// - public string ExcludeFilter { get; set; } = ""; + /// + /// Exclude filter string (element list in an arrary, seperated with semicolon ';') + /// + public string ExcludeFilter { get; set; } = ""; #endregion // EntitiesToExportTab diff --git a/Source/IFCExporterUIOverride/IFCExportConfigurationsMap.cs b/Source/IFCExporterUIOverride/IFCExportConfigurationsMap.cs index d54a48ca..f2b74404 100644 --- a/Source/IFCExporterUIOverride/IFCExportConfigurationsMap.cs +++ b/Source/IFCExporterUIOverride/IFCExportConfigurationsMap.cs @@ -194,6 +194,8 @@ public void AddSavedConfigurations() configuration.UseTypeNameOnlyForIfcType = bool.Parse(configMap[s_useTypeNameOnlyForIfcType]); if (configMap.ContainsKey(s_useVisibleRevitNameAsEntityName)) configuration.UseVisibleRevitNameAsEntityName = bool.Parse(configMap[s_useVisibleRevitNameAsEntityName]); + if (configMap.ContainsKey(s_exportAllPhases)) + configuration.ExportAllPhases = bool.Parse(configMap[s_exportAllPhases]); if (configMap.ContainsKey(s_useOnlyTriangulation)) configuration.UseOnlyTriangulation = bool.Parse(configMap[s_useOnlyTriangulation]); if (configMap.ContainsKey(s_setupTessellationLevelOfDetail)) @@ -296,6 +298,9 @@ public void AddSavedConfigurations() Field fieldUseVisibleRevitNameAsEntityName = m_schema.GetField(s_useVisibleRevitNameAsEntityName); if (fieldUseVisibleRevitNameAsEntityName != null) configuration.UseVisibleRevitNameAsEntityName = configEntity.Get(s_useVisibleRevitNameAsEntityName); + Field fieldExportAllPhases = m_schema.GetField(s_exportAllPhases); + if (fieldExportAllPhases != null) + configuration.ExportAllPhases = configEntity.Get(s_exportAllPhases); Field fieldTessellationLevelOfDetail = m_schema.GetField(s_setupTessellationLevelOfDetail); if (fieldTessellationLevelOfDetail != null) configuration.TessellationLevelOfDetail = configEntity.Get(s_setupTessellationLevelOfDetail); @@ -349,6 +354,7 @@ public void AddSavedConfigurations() private const string s_setupSitePlacement = "SitePlacement"; private const string s_useTypeNameOnlyForIfcType = "UseTypeNameOnlyForIfcType"; private const string s_useVisibleRevitNameAsEntityName = "UseVisibleRevitNameAsEntityName"; + private const string s_exportAllPhases = "ExportAllPhases"; // Used for COBie 2.4 private const string s_cobieCompanyInfo = "COBieCompanyInfo"; private const string s_cobieProjectInfo = "COBieProjectInfo"; diff --git a/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml b/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml index 40a6084e..eebfd8b0 100644 --- a/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml +++ b/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml @@ -65,6 +65,7 @@ + diff --git a/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml.cs b/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml.cs index 0acf5a55..1de80306 100644 --- a/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml.cs +++ b/Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml.cs @@ -257,7 +257,7 @@ private void UpdatePhaseAttributes(IFCExportConfiguration configuration) } } - comboboxActivePhase.IsEnabled = !configuration.VisibleElementsOfCurrentView; + comboboxActivePhase.IsEnabled = !(configuration.VisibleElementsOfCurrentView || configuration.ExportAllPhases); } /// @@ -326,6 +326,7 @@ private void UpdateActiveConfigurationOptions(IFCExportConfiguration configurati checkboxIncludeIfcSiteElevation.IsChecked = configuration.IncludeSiteElevation; checkboxStoreIFCGUID.IsChecked = configuration.StoreIFCGUID; checkBoxExportRoomsInView.IsChecked = configuration.ExportRoomsInView; + checkBoxExportAllPhases.IsChecked = configuration.ExportAllPhases; comboBoxLOD.SelectedIndex = (int)(Math.Round(configuration.TessellationLevelOfDetail * 4) - 1); checkboxIncludeSteelElements.IsChecked = configuration.IncludeSteelElements; comboBoxSitePlacement.SelectedIndex = (int)configuration.SitePlacement; @@ -373,6 +374,7 @@ private void UpdateActiveConfigurationOptions(IFCExportConfiguration configurati checkboxExportSchedulesAsPsets, checkBoxExportSpecificSchedules, checkBoxExportRoomsInView, + checkBoxExportAllPhases, checkBoxLevelOfDetails, comboboxActivePhase, checkboxExportUserDefinedPset, @@ -393,7 +395,7 @@ private void UpdateActiveConfigurationOptions(IFCExportConfiguration configurati { element.IsEnabled = !configuration.IsBuiltIn; } - comboboxActivePhase.IsEnabled = comboboxActivePhase.IsEnabled && !configuration.VisibleElementsOfCurrentView; + comboboxActivePhase.IsEnabled = comboboxActivePhase.IsEnabled && !(configuration.VisibleElementsOfCurrentView || configuration.ExportAllPhases); userDefinedPropertySetFileName.IsEnabled = userDefinedPropertySetFileName.IsEnabled && configuration.ExportUserDefinedPsets; userDefinedParameterMappingTable.IsEnabled = userDefinedParameterMappingTable.IsEnabled && configuration.ExportUserDefinedParameterMapping; buttonBrowse.IsEnabled = buttonBrowse.IsEnabled && configuration.ExportUserDefinedPsets; @@ -1411,6 +1413,17 @@ private void checkBoxExportRoomsInView_Checked(object sender, RoutedEventArgs e) } } + private void checkBoxExportAllPhases_Checked(object sender, RoutedEventArgs e) + { + CheckBox checkBox = (CheckBox)sender; + IFCExportConfiguration configuration = GetSelectedConfiguration(); + if (configuration != null) + { + configuration.ExportAllPhases = GetCheckbuttonChecked(checkBox); + UpdatePhaseAttributes(configuration); + } + } + private void comboBoxLOD_SelectionChanged(object sender, RoutedEventArgs e) { string selectedItem = (string)comboBoxLOD.SelectedItem; diff --git a/Source/IFCExporterUIOverride/Properties/Resources.Designer.cs b/Source/IFCExporterUIOverride/Properties/Resources.Designer.cs index 20add5d5..670abc4e 100644 --- a/Source/IFCExporterUIOverride/Properties/Resources.Designer.cs +++ b/Source/IFCExporterUIOverride/Properties/Resources.Designer.cs @@ -618,6 +618,15 @@ public static string Export { } } + /// + /// Looks up a localized string similar to Export all elements regardless of phase. + /// + public static string ExportAllPhases { + get { + return ResourceManager.GetString("ExportAllPhases", resourceCulture); + } + } + /// /// Looks up a localized string similar to Export base quantities. /// diff --git a/Source/IFCExporterUIOverride/Properties/Resources.de.resx b/Source/IFCExporterUIOverride/Properties/Resources.de.resx index d69178e9..88484c95 100644 --- a/Source/IFCExporterUIOverride/Properties/Resources.de.resx +++ b/Source/IFCExporterUIOverride/Properties/Resources.de.resx @@ -399,6 +399,9 @@ Export + + Alle Elemente unabhängig von der Phase exportieren + Nur in der Ansicht sichtbare Elemente exportieren diff --git a/Source/IFCExporterUIOverride/Properties/Resources.fr.resx b/Source/IFCExporterUIOverride/Properties/Resources.fr.resx index c22ecfae..041333ed 100644 --- a/Source/IFCExporterUIOverride/Properties/Resources.fr.resx +++ b/Source/IFCExporterUIOverride/Properties/Resources.fr.resx @@ -402,6 +402,9 @@ Exporter… + + Exporter tous les éléments, quelle que soit la phase + Exporter uniquement les éléments visibles dans la vue actuelle diff --git a/Source/IFCExporterUIOverride/Properties/Resources.resx b/Source/IFCExporterUIOverride/Properties/Resources.resx index c773b3ab..401bdb3c 100644 --- a/Source/IFCExporterUIOverride/Properties/Resources.resx +++ b/Source/IFCExporterUIOverride/Properties/Resources.resx @@ -374,6 +374,9 @@ Export + + Export all elements regardless of phase + Export only elements visible in current view diff --git a/Source/Revit.IFC.Common/Revit.IFC.Common.csproj b/Source/Revit.IFC.Common/Revit.IFC.Common.csproj index 47a8ebad..a67eba61 100644 --- a/Source/Revit.IFC.Common/Revit.IFC.Common.csproj +++ b/Source/Revit.IFC.Common/Revit.IFC.Common.csproj @@ -52,17 +52,33 @@ TRACE;IFC_OPENSOURCE + + ..\..\packages\Revit_All_Main_Versions_API_x64.2022.1.0\lib\net48\AdWindows.dll + False + False + + ..\..\packages\Revit_All_Main_Versions_API_x64.2022.1.0\lib\net48\RevitAPI.dll False - C:\Program Files\Autodesk\Revit 2022\RevitAPI.dll + False False C:\Program Files\Autodesk\Revit 2022\RevitAPIIFC.dll + + ..\..\packages\Revit_All_Main_Versions_API_x64.2022.1.0\lib\net48\RevitAPIUI.dll + False + False + + + ..\..\packages\Revit_All_Main_Versions_API_x64.2022.1.0\lib\net48\UIFramework.dll + False + False + @@ -116,6 +132,9 @@ true + + + xcopy "$(TargetPath)" "C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2022.bundle\Contents\2022\" /F /R /Y /I diff --git a/Source/Revit.IFC.Export/Utility/ElementFilteringUtil.cs b/Source/Revit.IFC.Export/Utility/ElementFilteringUtil.cs index 0d3e1faa..f47c7a31 100644 --- a/Source/Revit.IFC.Export/Utility/ElementFilteringUtil.cs +++ b/Source/Revit.IFC.Export/Utility/ElementFilteringUtil.cs @@ -99,7 +99,7 @@ private static ElementFilter GetExportFilter(Document document, ExporterIFC expo filters.Add(GetDesignOptionFilter()); // Phases: only for non-spatial elements. For spatial elements, we will do a check afterwards. - if (!forSpatialElements && !ExporterCacheManager.ExportOptionsCache.ExportingLink) + if (!forSpatialElements && !ExporterCacheManager.ExportOptionsCache.ExportingLink && !ExporterCacheManager.ExportOptionsCache.ExportAllPhases) filters.Add(GetPhaseStatusFilter(document)); return new LogicalAndFilter(filters); @@ -558,6 +558,8 @@ public static bool IsRoomInInvalidPhase(Element element) Parameter phaseParameter = element.get_Parameter(BuiltInParameter.ROOM_PHASE); if (phaseParameter != null) { + if (ExporterCacheManager.ExportOptionsCache.ExportAllPhases) + return true; ElementId phaseId = phaseParameter.AsElementId(); if (phaseId != ElementId.InvalidElementId && phaseId != ExporterCacheManager.ExportOptionsCache.ActivePhaseId) return true; diff --git a/Source/Revit.IFC.Export/Utility/ExportOptionsCache.cs b/Source/Revit.IFC.Export/Utility/ExportOptionsCache.cs index 1e8b3297..02338729 100644 --- a/Source/Revit.IFC.Export/Utility/ExportOptionsCache.cs +++ b/Source/Revit.IFC.Export/Utility/ExportOptionsCache.cs @@ -372,6 +372,9 @@ public static ExportOptionsCache Create(ExporterIFC exporterIFC, Document docume cache.ActiveView = activeView; } + bool? exportAllPhases = OptionsUtil.GetNamedBooleanOption(options, "ExportAllPhases"); + cache.ExportAllPhases = exportAllPhases.HasValue ? exportAllPhases.Value : false; + // "FileType" - note - setting is not respected yet ParseFileType(options, cache); @@ -729,6 +732,16 @@ public bool UseActiveViewGeometry set; } + /// + /// True to export all elements regardless of phase + /// False to use default export options. + /// + public bool ExportAllPhases + { + get; + set; + } + /// /// Whether or not export the Part element from host. /// Export Part element only if 'Current View Only' is checked and 'Show Parts' is selected.