Skip to content

Commit 225f7ce

Browse files
committed
Code update
1 parent ae7f00e commit 225f7ce

File tree

120 files changed

+10246
-7804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+10246
-7804
lines changed

Source/IFCExporterUIOverride/IFCCommandOverrideApplication.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
using Autodesk.Revit.DB.ExternalService;
3434

3535

36-
using SaveFileDialog = Microsoft.Win32.SaveFileDialog;
3736
using View = Autodesk.Revit.DB.View;
3837

3938
using System.Windows.Forms;
@@ -61,7 +60,6 @@ public Result OnShutdown(UIControlledApplication application)
6160
{
6261
// Clean up
6362
m_ifcCommandBinding.Executed -= OnIFCExport;
64-
6563
return Result.Succeeded;
6664
}
6765

@@ -106,7 +104,7 @@ private void ApplicationInitialized(object sender, ApplicationInitializedEventAr
106104
entUIService.AddServer(browseIFCEntityServer);
107105
entUIService.SetActiveServer(browseIFCEntityServer.GetServerId());
108106
}
109-
catch {}
107+
catch { }
110108
}
111109
}
112110

@@ -255,7 +253,7 @@ public void OnIFCExport(object sender, CommandEventArgs args)
255253
// one of the exports. Prevent that by keeping track of the exported file names.
256254
ISet<string> exportedFileNames = new HashSet<string>();
257255

258-
bool exportLinks =
256+
bool exportLinks =
259257
selectedConfig.ExportLinkedFiles != LinkedFileExportAs.DontExport;
260258
bool exportSeparateLinks =
261259
selectedConfig.ExportLinkedFiles == LinkedFileExportAs.ExportAsSeparate;
@@ -295,10 +293,7 @@ public void OnIFCExport(object sender, CommandEventArgs args)
295293
selectedConfig.ActiveViewId = selectedConfig.UseActiveViewGeometry ? activeViewId : ElementId.InvalidElementId;
296294
selectedConfig.UpdateOptions(exportOptions, activeViewId);
297295

298-
// This will eventually become an option. Hardwired for testing to be
299-
// NOT exporting linked files as separate IFC files.
300-
301-
IDictionary<ElementId, string> linkGUIDsCache =
296+
IDictionary<ElementId, string> linkGUIDsCache =
302297
new Dictionary<ElementId, string>();
303298

304299
IDictionary<RevitLinkInstance, Transform> linkInstanceTranforms = null;
@@ -540,14 +535,14 @@ private string GetLinkFileName(Document linkDocument, string linkPathName)
540535
if (tr.HasReflection)
541536
{
542537
instHasReflection.Add(instanceId);
543-
numBadInstances++;
538+
numBadInstances++;
544539
continue;
545540
}
546541

547542
if (!MathUtil.IsAlmostEqual(tr.Determinant, 1.0))
548543
{
549544
scaledInst.Add(instanceId);
550-
numBadInstances++;
545+
numBadInstances++;
551546
continue;
552547
}
553548

@@ -584,10 +579,10 @@ public bool IsLinkVisible(Element element, View filterView)
584579
return false;
585580

586581
return filterView.IsElementVisibleInTemporaryViewMode(TemporaryViewMode.TemporaryHideIsolate, element.Id);
587-
}
582+
}
588583

589584
public void ExportLinkedDocuments(Document document, string fileName,
590-
IDictionary<ElementId, string> linkGUIDsCache,
585+
IDictionary<ElementId, string> linkGUIDsCache,
591586
IDictionary<RevitLinkInstance, Transform> idToTransform,
592587
IFCExportOptions exportOptions, ElementId originalFilterViewId)
593588
{

Source/IFCExporterUIOverride/IFCExport.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ private void buttonExport_Click(object sender, RoutedEventArgs args)
507507
return;
508508
}
509509

510+
TheDocument.Application.WriteJournalComment(@"Jrn.Data ""File Name"", ""IDOK"", " + @"""" + textBoxSetupFileName.Text + @"""", true);
511+
510512
IFCExportConfiguration selectedConfig = GetSelectedConfiguration();
511513
if (OptionsUtil.ExportAs4DesignTransferView(selectedConfig.IFCVersion))
512514
{
@@ -527,7 +529,8 @@ private void buttonExport_Click(object sender, RoutedEventArgs args)
527529
selectedConfig = LastSelectedConfig[selectedConfig.Name];
528530

529531
// This check will be done only for IFC4 and above as this only affects IfcMapConversion use that starts in IFC4 onward
530-
if (!OptionsUtil.ExportAsOlderThanIFC4(selectedConfig.IFCVersion))
532+
if (!OptionsUtil.ExportAsOlderThanIFC4(selectedConfig.IFCVersion) &&
533+
!string.IsNullOrWhiteSpace(selectedConfig.GeoRefEPSGCode))
531534
{
532535
// Check whether the resulting offset (to wcs) will be too large due to geo-reference information, raise warning
533536
BasePoint surveyPoint = BasePoint.GetSurveyPoint(TheDocument);

Source/IFCExporterUIOverride/IFCExportConfiguration.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,23 @@ public class IFCExportConfiguration
5858
/// </summary>
5959
public IFCVersion IFCVersion { get; set; } = IFCVersion.IFC2x3CV2;
6060

61-
private KnownERNames exchangeRequirement = KnownERNames.NotDefined;
61+
private KnownERNames m_ExchangeRequirement = KnownERNames.NotDefined;
6262

6363
public KnownERNames ExchangeRequirement
6464
{
6565
get
6666
{
67-
return exchangeRequirement;
67+
return m_ExchangeRequirement;
6868
}
6969
set
7070
{
7171
if (IFCExchangeRequirements.ExchangeRequirements.ContainsKey(IFCVersion))
7272
{
7373
IList<KnownERNames> erList = IFCExchangeRequirements.ExchangeRequirements[IFCVersion];
7474
if (erList != null && erList.Contains(value))
75-
exchangeRequirement = value;
75+
{
76+
m_ExchangeRequirement = value;
77+
}
7678
}
7779
}
7880
}
@@ -286,6 +288,15 @@ public KnownERNames ExchangeRequirement
286288
/// </summary>
287289
public bool UseTypeNameOnlyForIfcType { get; set; } = false;
288290

291+
/// <summary>
292+
/// Don't create a container entity for floors and roofs unless exporting parts
293+
/// </summary>
294+
public bool ExportHostAsSingleEntity { get; set; } = false;
295+
296+
/// <summary>
297+
/// Use Author field in Project Information to set IfcOwnerHistory LastModified attribute
298+
/// </summary>
299+
public bool OwnerHistoryLastModified { get; set; } = false;
289300
/// <summary>
290301
/// Value indicating whether the IFC Entity Name will use visible Revit Name
291302
/// </summary>
@@ -593,7 +604,9 @@ public void UpdateBuiltInConfiguration(IFCExportConfiguration updatedConfig)
593604
/// <param name="filterViewId">The id of the view that will be used to select which elements to export.</param>
594605
public void UpdateOptions(IFCExportOptions options, ElementId filterViewId)
595606
{
596-
JavaScriptSerializer ser = new JavaScriptSerializer();
607+
JavaScriptSerializer ser = new JavaScriptSerializer();
608+
options.FilterViewId = VisibleElementsOfCurrentView ? filterViewId : ElementId.InvalidElementId;
609+
597610
foreach (var prop in GetType().GetProperties())
598611
{
599612
switch (prop.Name)
@@ -605,7 +618,7 @@ public void UpdateOptions(IFCExportOptions options, ElementId filterViewId)
605618
options.FileVersion = IFCVersion;
606619
break;
607620
case "ActivePhaseId":
608-
if (IFCPhaseAttributes.Validate(ActivePhaseId))
621+
if (options.FilterViewId == ElementId.InvalidElementId && IFCPhaseAttributes.Validate(ActivePhaseId))
609622
options.AddOption(prop.Name, ActivePhaseId.ToString());
610623
break;
611624
case "SpaceBoundaries":
@@ -632,8 +645,6 @@ public void UpdateOptions(IFCExportOptions options, ElementId filterViewId)
632645
break;
633646
}
634647
}
635-
636-
options.FilterViewId = VisibleElementsOfCurrentView ? filterViewId : ElementId.InvalidElementId;
637648
}
638649

639650

Source/IFCExporterUIOverride/IFCExportConfigurationsMap.cs

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ public void AddSavedConfigurations()
202202
Field fieldTessellationLevelOfDetail = m_OldSchema.GetField(s_setupTessellationLevelOfDetail);
203203
if (fieldTessellationLevelOfDetail != null)
204204
configuration.TessellationLevelOfDetail = configEntity.Get<double>(s_setupTessellationLevelOfDetail);
205+
Field fieldOwnerHistoryLastModified = m_OldSchema.GetField(s_ownerHistoryLastModified);
206+
if (fieldOwnerHistoryLastModified != null)
207+
configuration.OwnerHistoryLastModified = configEntity.Get<bool>(s_ownerHistoryLastModified);
205208

206209
AddOrReplace(configuration);
207210
}
@@ -286,6 +289,8 @@ public void AddSavedConfigurations()
286289
configuration.UseVisibleRevitNameAsEntityName = bool.Parse(configMap[s_useVisibleRevitNameAsEntityName]);
287290
if (configMap.ContainsKey(s_useOnlyTriangulation))
288291
configuration.UseOnlyTriangulation = bool.Parse(configMap[s_useOnlyTriangulation]);
292+
if (configMap.ContainsKey(s_ownerHistoryLastModified))
293+
configuration.OwnerHistoryLastModified = bool.Parse(configMap[s_ownerHistoryLastModified]);
289294
if (configMap.ContainsKey(s_setupTessellationLevelOfDetail))
290295
configuration.TessellationLevelOfDetail = double.Parse(configMap[s_setupTessellationLevelOfDetail]);
291296
if (configMap.ContainsKey(s_setupSitePlacement))
@@ -333,6 +338,7 @@ public void AddSavedConfigurations()
333338
catch (Exception)
334339
{
335340
// don't skip all configurations if an exception occurs for one
341+
IFCCommandOverrideApplication.TheDocument.Application.WriteJournalComment("IFC error: Cannot read IFCExportConfigurationMap schema", true);
336342
}
337343
}
338344
}
@@ -393,6 +399,7 @@ public void AddSavedConfigurations()
393399
private const string s_setupSitePlacement = "SitePlacement";
394400
private const string s_useTypeNameOnlyForIfcType = "UseTypeNameOnlyForIfcType";
395401
private const string s_useVisibleRevitNameAsEntityName = "UseVisibleRevitNameAsEntityName";
402+
private const string s_ownerHistoryLastModified = "OwnerHistoryLastModified";
396403
// Used for COBie 2.4
397404
private const string s_cobieCompanyInfo = "COBieCompanyInfo";
398405
private const string s_cobieProjectInfo = "COBieProjectInfo";
@@ -514,52 +521,48 @@ public void UpdateSavedConfigurations(IFCExportConfigurationsMap initialConfigs)
514521
m_jsonSchema = builder.Finish();
515522
}
516523

517-
// It won't start any transaction if there is no change to the configurations
518-
if (setupsToSave.Count > 0)
524+
// Overwrite all saved configs with the new list
525+
Transaction transaction = new Transaction(IFCCommandOverrideApplication.TheDocument, Properties.Resources.UpdateExportSetups);
526+
try
519527
{
520-
// Overwrite all saved configs with the new list
521-
Transaction transaction = new Transaction(IFCCommandOverrideApplication.TheDocument, Properties.Resources.UpdateExportSetups);
522-
try
528+
transaction.Start(Properties.Resources.SaveConfigurationChanges);
529+
IList<DataStorage> savedConfigurations = GetSavedConfigurations(m_jsonSchema);
530+
int savedConfigurationCount = savedConfigurations.Count<DataStorage>();
531+
int savedConfigurationIndex = 0;
532+
foreach (IFCExportConfiguration configuration in setupsToSave)
523533
{
524-
transaction.Start(Properties.Resources.SaveConfigurationChanges);
525-
IList<DataStorage> savedConfigurations = GetSavedConfigurations(m_jsonSchema);
526-
int savedConfigurationCount = savedConfigurations.Count<DataStorage>();
527-
int savedConfigurationIndex = 0;
528-
foreach (IFCExportConfiguration configuration in setupsToSave)
534+
DataStorage configStorage;
535+
if (savedConfigurationIndex >= savedConfigurationCount)
529536
{
530-
DataStorage configStorage;
531-
if (savedConfigurationIndex >= savedConfigurationCount)
532-
{
533-
configStorage = DataStorage.Create(IFCCommandOverrideApplication.TheDocument);
534-
}
535-
else
536-
{
537-
configStorage = savedConfigurations[savedConfigurationIndex];
538-
savedConfigurationIndex++;
539-
}
540-
541-
Entity mapEntity = new Entity(m_jsonSchema);
542-
string configData = configuration.SerializeConfigToJson();
543-
mapEntity.Set<string>(s_configMapField, configData);
544-
configStorage.SetEntity(mapEntity);
537+
configStorage = DataStorage.Create(IFCCommandOverrideApplication.TheDocument);
545538
}
546-
547-
List<ElementId> elementsToDelete = new List<ElementId>();
548-
for (; savedConfigurationIndex < savedConfigurationCount; savedConfigurationIndex++)
539+
else
549540
{
550-
DataStorage configStorage = savedConfigurations[savedConfigurationIndex];
551-
elementsToDelete.Add(configStorage.Id);
541+
configStorage = savedConfigurations[savedConfigurationIndex];
542+
savedConfigurationIndex++;
552543
}
553-
if (elementsToDelete.Count > 0)
554-
IFCCommandOverrideApplication.TheDocument.Delete(elementsToDelete);
555-
556-
transaction.Commit();
544+
545+
Entity mapEntity = new Entity(m_jsonSchema);
546+
string configData = configuration.SerializeConfigToJson();
547+
mapEntity.Set<string>(s_configMapField, configData);
548+
configStorage.SetEntity(mapEntity);
557549
}
558-
catch (System.Exception)
550+
551+
List<ElementId> elementsToDelete = new List<ElementId>();
552+
for (; savedConfigurationIndex < savedConfigurationCount; savedConfigurationIndex++)
559553
{
560-
if (transaction.HasStarted())
561-
transaction.RollBack();
554+
DataStorage configStorage = savedConfigurations[savedConfigurationIndex];
555+
elementsToDelete.Add(configStorage.Id);
562556
}
557+
if (elementsToDelete.Count > 0)
558+
IFCCommandOverrideApplication.TheDocument.Delete(elementsToDelete);
559+
560+
transaction.Commit();
561+
}
562+
catch (System.Exception)
563+
{
564+
if (transaction.HasStarted())
565+
transaction.RollBack();
563566
}
564567
}
565568

Source/IFCExporterUIOverride/IFCExporterUIOverride.csproj

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,20 @@
4747
<OutputPath>bin\Releasex64\</OutputPath>
4848
</PropertyGroup>
4949
<ItemGroup>
50-
<Reference Include="Autodesk.UI.Windows">
50+
<Reference Include="Autodesk.UI.Windows, Version=3.2.0.0, Culture=neutral, processorArchitecture=MSIL">
51+
<SpecificVersion>False</SpecificVersion>
5152
<HintPath>..\..\..\..\Program Files\Autodesk\Revit 2024\Autodesk.UI.Windows.dll</HintPath>
5253
</Reference>
53-
<Reference Include="RevitAPI">
54+
<Reference Include="RevitAPI, Version=24.0.0.0, Culture=neutral, processorArchitecture=AMD64">
55+
<SpecificVersion>False</SpecificVersion>
5456
<HintPath>..\..\..\..\Program Files\Autodesk\Revit 2024\RevitAPI.dll</HintPath>
5557
</Reference>
56-
<Reference Include="RevitAPIIFC">
58+
<Reference Include="RevitAPIIFC, Version=24.0.0.0, Culture=neutral, processorArchitecture=AMD64">
59+
<SpecificVersion>False</SpecificVersion>
5760
<HintPath>..\..\..\..\Program Files\Autodesk\Revit 2024\RevitAPIIFC.dll</HintPath>
5861
</Reference>
59-
<Reference Include="RevitAPIUI">
62+
<Reference Include="RevitAPIUI, Version=24.0.0.0, Culture=neutral, processorArchitecture=AMD64">
63+
<SpecificVersion>False</SpecificVersion>
6064
<HintPath>..\..\..\..\Program Files\Autodesk\Revit 2024\RevitAPIUI.dll</HintPath>
6165
</Reference>
6266
<Reference Include="System" />
@@ -73,7 +77,8 @@
7377
<Reference Include="System.Xaml">
7478
<RequiredTargetFramework>4.0</RequiredTargetFramework>
7579
</Reference>
76-
<Reference Include="UserInterfaceUtility">
80+
<Reference Include="UserInterfaceUtility, Version=24.0.0.0, Culture=neutral, processorArchitecture=MSIL">
81+
<SpecificVersion>False</SpecificVersion>
7782
<HintPath>..\..\..\..\Program Files\Autodesk\Revit 2024\UserInterfaceUtility.dll</HintPath>
7883
</Reference>
7984
<Reference Include="WindowsBase" />

Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
<CheckBox Content="{x:Static p:Resources.UseOnlyTriangulation}" Margin="10,175,0,0" x:Name="checkBox_TriangulationOnly" Checked="checkBox_TriangulationOnly_Checked" Unchecked="checkBox_TriangulationOnly_Unchecked" ToolTip="{x:Static p:Resources.TriangulationOnlyTooltip}" HorizontalAlignment="Left" Width="588" Height="15" VerticalAlignment="Top"/>
8585
<CheckBox Content="{x:Static p:Resources.UseTypeNameOnlyForIfcType}" Margin="10,196,0,0" x:Name="checkbox_UseTypeNameOnly" Checked="Checkbox_UseTypeNameOnly_Checked" Unchecked="Checkbox_UseTypeNameOnly_Unchecked" ToolTip="{x:Static p:Resources.UseTypeNameOnlyTooltip}" HorizontalAlignment="Left" Width="588" Height="15" VerticalAlignment="Top"/>
8686
<CheckBox Content="{x:Static p:Resources.UseVisibleRevitNameAsEntityName}" Margin="10,217,0,0" x:Name="checkbox_UseVisibleRevitNameAsEntityName" Checked="Checkbox_UseVisibleRevitName_Checked" Unchecked="Checkbox_UseVisibleRevitName_Unchecked" ToolTip="{x:Static p:Resources.UseVisibleRevitNameTooltip}" Height="19" VerticalAlignment="Top" HorizontalAlignment="Left" Width="588"/>
87-
<Button x:Name="button_ExcludeElement" Content="{x:Static p:Resources.ExcludeEntitySelection}" Margin="16,0,0,12" Height="23" VerticalAlignment="Bottom" HorizontalAlignment="Left" Padding="5,0,5,0" Click="button_ExcludeElement_Click"/>
87+
<CheckBox Content="{x:Static p:Resources.OwnerHistoryLastModified}" Margin="10,259,0,0" x:Name="checkbox_OwnerHistoryLastModified" Checked="Checkbox_OwnerHistoryLastModified_Checked" Unchecked="Checkbox_OwnerHistoryLastModified_Unchecked" ToolTip="{x:Static p:Resources.OwnerHistoryLastModifiedTooltip}" Height="19" VerticalAlignment="Top" HorizontalAlignment="Left" Width="588"/>
88+
<Button x:Name="button_ExcludeElement" Content="{x:Static p:Resources.ExcludeEntitySelection}" Margin="16,0,0,12" Height="23" VerticalAlignment="Bottom" HorizontalAlignment="Left" Padding="5,0,5,0" Click="button_ExcludeElement_Click"/>
8889
</Grid>
8990
</TabItem>
9091
<TabItem Header="{x:Static p:Resources.GeoReference}" HorizontalAlignment="Stretch" Height="21" VerticalAlignment="Top" Margin="-2,0,0,0">

0 commit comments

Comments
 (0)