Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revit2018 - Added new option 'Relate doors to rooms' #95

Open
wants to merge 15 commits into
base: Revit2018
Choose a base branch
from
Open
13 changes: 9 additions & 4 deletions Revit.IFC.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Jo64 marked this conversation as resolved.
Show resolved Hide resolved

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.421
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revit.IFC.Import", "Source\Revit.IFC.Import\Revit.IFC.Import.csproj", "{7F987D09-9716-4F50-ADE0-278E4B537101}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revit.IFC.Export", "Source\Revit.IFC.Export\Revit.IFC.Export.csproj", "{BCE5141A-291B-4CD8-A69B-7B9345AA00E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revit.IFC.Common", "Source\Revit.IFC.Common\Revit.IFC.Common.csproj", "{032EA4DC-181F-4453-9F93-E08DE1C07D95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IFCExporterUI", "Source\IFCExporterUIOverride\IFCExporterUIOverride.csproj", "{BF694550-5BEB-4DCF-8EC2-A5904690DC17}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IFCExporterUIOverride", "Source\IFCExporterUIOverride\IFCExporterUIOverride.csproj", "{BF694550-5BEB-4DCF-8EC2-A5904690DC17}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Install", "Install", "{88C55E9A-2767-48B7-A035-E3D864C4FF09}"
EndProject
Expand Down Expand Up @@ -64,7 +67,6 @@ Global
{BF694550-5BEB-4DCF-8EC2-A5904690DC17}.Release|x86.ActiveCfg = Release|Any CPU
{7DFBD495-C588-4C7B-B8F6-5B793ADB06F2}.Debug|Any CPU.ActiveCfg = Debug|x86
{7DFBD495-C588-4C7B-B8F6-5B793ADB06F2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{7DFBD495-C588-4C7B-B8F6-5B793ADB06F2}.Debug|Mixed Platforms.Build.0 = Debug|x86
{7DFBD495-C588-4C7B-B8F6-5B793ADB06F2}.Debug|x86.ActiveCfg = Debug|x86
{7DFBD495-C588-4C7B-B8F6-5B793ADB06F2}.Debug|x86.Build.0 = Debug|x86
{7DFBD495-C588-4C7B-B8F6-5B793ADB06F2}.Release|Any CPU.ActiveCfg = Release|x86
Expand All @@ -79,6 +81,9 @@ Global
GlobalSection(NestedProjects) = preSolution
{7DFBD495-C588-4C7B-B8F6-5B793ADB06F2} = {88C55E9A-2767-48B7-A035-E3D864C4FF09}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ED91B8E4-8D06-41AB-9215-6FCB84646950}
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
Expand Down
7 changes: 7 additions & 0 deletions Source/IFCExporterUIOverride/IFCExportConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ public class IFCExportConfiguration
/// </summary>
public string COBieProjectInfo { get; set; } = "";

public bool DoorBelongsToRoom { get; set; }

/// <summary>
/// Value indicating whether steel elements should be exported.
/// </summary>
Expand Down Expand Up @@ -292,6 +294,7 @@ private IFCExportConfiguration()
this.ExportSpecificSchedules = false;
this.TessellationLevelOfDetail = 0.5;
this.UseOnlyTriangulation = false;
this.DoorBelongsToRoom = false;
this.StoreIFCGUID = false;
this.m_isBuiltIn = false;
this.m_isInSession = false;
Expand Down Expand Up @@ -360,6 +363,7 @@ private IFCExportConfiguration()
// The default tesselationLevelOfDetail will be low
configuration.TessellationLevelOfDetail = 0.5;
configuration.UseOnlyTriangulation = false;
configuration.DoorBelongsToRoom = false;
configuration.StoreIFCGUID = false;
configuration.m_isBuiltIn = true;
configuration.m_isInSession = false;
Expand Down Expand Up @@ -410,6 +414,7 @@ private IFCExportConfiguration(IFCExportConfiguration other)
this.IncludeSiteElevation = other.IncludeSiteElevation;
this.TessellationLevelOfDetail = other.TessellationLevelOfDetail;
this.UseOnlyTriangulation = other.UseOnlyTriangulation;
this.DoorBelongsToRoom = other.DoorBelongsToRoom;
this.StoreIFCGUID = other.StoreIFCGUID;
this.m_isBuiltIn = other.m_isBuiltIn;
this.m_isInSession = other.m_isInSession;
Expand Down Expand Up @@ -465,6 +470,7 @@ private IFCExportConfiguration(String name, IFCExportConfiguration other)
this.IncludeSiteElevation = other.IncludeSiteElevation;
this.TessellationLevelOfDetail = other.TessellationLevelOfDetail;
this.UseOnlyTriangulation = other.UseOnlyTriangulation;
this.DoorBelongsToRoom = other.DoorBelongsToRoom;
this.ActivePhaseId = other.ActivePhaseId;
this.ExportRoomsInView = other.ExportRoomsInView;
this.m_isBuiltIn = false;
Expand Down Expand Up @@ -538,6 +544,7 @@ public void UpdateOptions(IFCExportOptions options, ElementId filterViewId)
options.AddOption("SitePlacement", SitePlacement.ToString());
options.AddOption("TessellationLevelOfDetail", TessellationLevelOfDetail.ToString());
options.AddOption("UseOnlyTriangulation", UseOnlyTriangulation.ToString());
options.AddOption("DoorBelongsToRoom", DoorBelongsToRoom.ToString());
options.AddOption("ActiveViewId", ActiveViewId.ToString());
options.AddOption("StoreIFCGUID", StoreIFCGUID.ToString());

Expand Down
3 changes: 2 additions & 1 deletion Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
<CheckBox Content="{x:Static p:Resources.IncludeIfcSiteElevation}" Height="16" HorizontalAlignment="Left" Margin="-74,107,0,0" x:Name="checkboxIncludeIfcSiteElevation" VerticalAlignment="Top" Checked="checkboxIfcSiteElevation_Checked" Unchecked="checkboxIfcSiteElevation_Checked" Width="569" Grid.ColumnSpan="5" />
<CheckBox Content="{x:Static p:Resources.StoreIFCGUID}" Height="16" HorizontalAlignment="Left" Margin="-74,127,0,0" x:Name="checkboxStoreIFCGUID" VerticalAlignment="Top" Checked="checkboxStoreIFCGUID_Checked" Unchecked="checkboxStoreIFCGUID_Checked" Width="569" Grid.ColumnSpan="5" />
<CheckBox Content="{x:Static p:Resources.ExportBoundingBox}" Height="16" HorizontalAlignment="Left" Margin="-74,147,0,0" Name="checkboxExportBoundingBox" VerticalAlignment="Top" Checked="checkboxExportBoundingBox_Checked" Unchecked="checkboxExportBoundingBox_Checked" Width="569" Grid.ColumnSpan="5" />
<CheckBox Content="{x:Static p:Resources.UseOnlyTriangulation}" Margin="-74,167,0,101" Grid.ColumnSpan="5" x:Name="checkBox_TriangulationOnly" Checked="checkBox_TriangulationOnly_Checked" Unchecked="checkBox_TriangulationOnly_Unchecked" ToolTip="Use this option if any tessellated geometry should remain as triangulated faces, or if the export performance is affected"/>
<CheckBox Content="{x:Static p:Resources.UseOnlyTriangulation}" Margin="-74,167,0,0" Grid.ColumnSpan="5" x:Name="checkBox_TriangulationOnly" Checked="checkBox_TriangulationOnly_Checked" Unchecked="checkBox_TriangulationOnly_Unchecked" ToolTip="Use this option if any tessellated geometry should remain as triangulated faces, or if the export performance is affected" />
<CheckBox Content="{x:Static p:Resources.DoorBelongsToRoom}" Height="16" Margin="-74,187,0,81" Grid.ColumnSpan="5" x:Name="checkBox_DoorBelongsToRoom" Checked="CheckBox_DoorBelongsToRoom_Checked" Unchecked="CheckBox_DoorBelongsToRoom_Unchecked" ToolTip="Use this option if the door belongs to the room and not to the building storey" />
</Grid>
</TabItem>
<!--
Expand Down
12 changes: 12 additions & 0 deletions Source/IFCExporterUIOverride/IFCExporterUIWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1726,5 +1726,17 @@ private void checkboxIncludeSteelElements_Unchecked(object sender, RoutedEventAr
IFCExportConfiguration configuration = GetSelectedConfiguration();
configuration.IncludeSteelElements = false;
}

private void CheckBox_DoorBelongsToRoom_Checked(object sender, RoutedEventArgs e)
{
IFCExportConfiguration configuration = GetSelectedConfiguration();
configuration.DoorBelongsToRoom = true;
}
private void CheckBox_DoorBelongsToRoom_Unchecked(object sender, RoutedEventArgs e)
{
IFCExportConfiguration configuration = GetSelectedConfiguration();
configuration.DoorBelongsToRoom = false;
}

}
}
9 changes: 9 additions & 0 deletions Source/IFCExporterUIOverride/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Source/IFCExporterUIOverride/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -789,4 +789,7 @@
<data name="UseOnlyTriangulation" xml:space="preserve">
<value>Keep Tessellated Geometry as Triangulation</value>
</data>
<data name="DoorBelongsToRoom" xml:space="preserve">
<value>The door (IfcDoor) belongs to the room (IfcSpace)</value>
</data>
</root>
4 changes: 2 additions & 2 deletions Source/Revit.IFC.Common/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
[assembly: AssemblyTrademark("")]
Jo64 marked this conversation as resolved.
Show resolved Hide resolved
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("19.1.0.0")]
[assembly: AssemblyFileVersion("19.1.0.0")]
[assembly: AssemblyVersion("18.4.1.0")]
[assembly: AssemblyFileVersion("18.4.1.0")]

#region Using directives

Expand Down
13 changes: 13 additions & 0 deletions Source/Revit.IFC.Export/Exporter/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3353,6 +3353,19 @@ private void RelateLevels(ExporterIFC exporterIFC, Document document)
HashSet<IFCAnyHandle> relatedProducts = RemoveContainedHandlesFromSet(relatedProductsToCheck);
HashSet<IFCAnyHandle> relatedElements = RemoveContainedHandlesFromSet(relatedElementsToCheck);

// ------------------------------------------------------------------------------
// Jo64
if (ExporterCacheManager.ExportOptionsCache.DoorBelongsToRoom.GetValueOrDefault())
{
var n = relatedElements.RemoveWhere
(
//item => item.TypeName.Equals("IfcDoor", StringComparison.OrdinalIgnoreCase)
//&&
item => ExporterCacheManager.DoorBelongsToRoomCache.Contains(item)
);
}
// ------------------------------------------------------------------------------

// skip coincident levels, if any.
for (int jj = ii + 1; jj < nextLevelIdx; jj++)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Revit.IFC.Export/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
[assembly: AssemblyTrademark("")]
Jo64 marked this conversation as resolved.
Show resolved Hide resolved
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("19.1.0.0")]
[assembly: AssemblyFileVersion("19.1.0.0")]
[assembly: AssemblyVersion("18.4.1.0")]
[assembly: AssemblyFileVersion("18.4.1.0")]

#region Using directives

Expand Down
3 changes: 3 additions & 0 deletions Source/Revit.IFC.Export/Revit.IFC.Export.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Slow_Debug|x64'">
Jo64 marked this conversation as resolved.
Show resolved Hide resolved
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Antlr4.Runtime, Version=4.6.0.0, Culture=neutral, PublicKeyToken=09abb75b9ed49849, processorArchitecture=MSIL">
<HintPath>..\..\packages\Antlr4.Runtime.4.6.4\lib\net45\Antlr4.Runtime.dll</HintPath>
Expand Down
31 changes: 31 additions & 0 deletions Source/Revit.IFC.Export/Toolkit/IFCInstanceExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5847,6 +5847,37 @@ public static IFCAnyHandle CreateCurveBoundedSurface(IFCFile file, IFCAnyHandle
IFCAnyHandle door = CreateInstance(exporterIFC.GetFile(), IFCEntityType.IfcDoor, element);
IFCAnyHandleUtil.SetAttribute(door, "OverallHeight", overallHeight);
IFCAnyHandleUtil.SetAttribute(door, "OverallWidth", overallWidth);

// ------------------------------------------------------------------------------
// Jo64
if (ExporterCacheManager.ExportOptionsCache.DoorBelongsToRoom.GetValueOrDefault())
{
var familyInstance = element as FamilyInstance;
if (familyInstance != null)
{
ElementId roomId;

var toRoomId = ((FamilyInstance)element).ToRoom?.Id;
if (toRoomId != null)
roomId = toRoomId;
else
roomId = ((FamilyInstance)element).Room?.Id;

//var fromRoomId = ((FamilyInstance)element).FromRoom?.Id;
if (roomId != null)
{
bool containedInSpace = (roomId != ElementId.InvalidElementId);
if (containedInSpace)
{
ExporterCacheManager.DoorBelongsToRoomCache.Add(door);
ExporterCacheManager.SpaceInfoCache.RelateToSpace(roomId, door);
}
}
}
}
// ------------------------------------------------------------------------------


if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
{
string validatedPreDefinedType = IFCValidateEntry.ValidateStrEnum<IFC4.IFCDoorType>(preDefinedType);
Expand Down
7 changes: 7 additions & 0 deletions Source/Revit.IFC.Export/Utility/ExportOptionsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ public static ExportOptionsCache Create(ExporterIFC exporterIFC, Document docume
bool? includeSteelElements = GetNamedBooleanOption(options, "IncludeSteelElements");
cache.IncludeSteelElements = includeSteelElements.HasValue && includeSteelElements.Value;

cache.DoorBelongsToRoom = GetNamedBooleanOption(options, "DoorBelongsToRoom");

// There is a bug in the native code that doesn't allow us to cast the filterView to any sub-type of View. Work around this by re-getting the element pointer.
if (filterView != null)
cache.FilterViewForExport = filterView.Document.GetElement(filterView.Id) as View;
Expand Down Expand Up @@ -744,6 +746,11 @@ public bool ExportAs2x3COBIE24DesignDeliverable
}
}

/// <summary>
///
/// </summary>
public bool? DoorBelongsToRoom { get; set; }

/// <summary>
/// Cache variable for the export annotations override (if set independently via the UI or API inputs)
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions Source/Revit.IFC.Export/Utility/ExporterCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@ public class ExporterCacheManager
/// </summary>
static IDictionary<Tuple<string, string>, string> m_PropertyMapCache;

// ---------------------------------------------
// Jo64
static HashSet<IFCAnyHandle> m_DoorBelongsToRoomCache;
public static HashSet<IFCAnyHandle> DoorBelongsToRoomCache
{
get
{
if (m_DoorBelongsToRoomCache == null)
m_DoorBelongsToRoomCache = new HashSet<IFCAnyHandle>();
return m_DoorBelongsToRoomCache;
}
}
// ---------------------------------------------

/// <summary>
/// The ParameterCache object.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/Revit.IFC.Import/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
[assembly: AssemblyTrademark("")]
Jo64 marked this conversation as resolved.
Show resolved Hide resolved
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("19.1.0.0")]
[assembly: AssemblyFileVersion("19.1.0.0")]
[assembly: AssemblyVersion("18.4.1.0")]
[assembly: AssemblyFileVersion("18.4.1.0")]

#region Using directives

Expand Down