197 lines
5.0 KiB
C#
197 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.DB.IFC;
|
|
using Autodesk.Revit.Exceptions;
|
|
|
|
namespace IFC_Revit_Interop
|
|
{
|
|
// Token: 0x02000019 RID: 25
|
|
internal class CurtainParentFinder
|
|
{
|
|
// Token: 0x0600007A RID: 122 RVA: 0x00006EAB File Offset: 0x000050AB
|
|
public CurtainParentFinder(ParentFinder host)
|
|
{
|
|
this.host = host;
|
|
this.doc = host.doc;
|
|
}
|
|
|
|
// Token: 0x0600007B RID: 123 RVA: 0x00006EC8 File Offset: 0x000050C8
|
|
public void Find()
|
|
{
|
|
foreach (Element element2 in this.host.coll.Where((Element element) => element is Wall || element is FootPrintRoof || element is ExtrusionRoof || element is CurtainSystem))
|
|
{
|
|
try
|
|
{
|
|
ICollection<ElementId> curtainChildren = this.GetCurtainChildren(element2);
|
|
if (curtainChildren != null)
|
|
{
|
|
foreach (ElementId elementId in curtainChildren)
|
|
{
|
|
this.host.ChildToParent[elementId.IntegerValue] = element2.Id.IntegerValue;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.host.log.WriteException("ERR_CurtainParentFinder", ex);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600007C RID: 124 RVA: 0x00006FC0 File Offset: 0x000051C0
|
|
private ICollection<ElementId> GetCurtainChildren(Element hostElement)
|
|
{
|
|
CurtainGridSet curtainGridSet = this.GetCurtainGridSet(hostElement);
|
|
if (curtainGridSet == null && hostElement is Wall)
|
|
{
|
|
return ExporterIFCUtils.GetLegacyCurtainSubElements(hostElement);
|
|
}
|
|
if (curtainGridSet.Size == 0)
|
|
{
|
|
return null;
|
|
}
|
|
return this.GetSubElements(curtainGridSet);
|
|
}
|
|
|
|
// Token: 0x0600007D RID: 125 RVA: 0x00006FF8 File Offset: 0x000051F8
|
|
private CurtainGridSet GetCurtainGridSet(Element element)
|
|
{
|
|
CurtainGridSet curtainGridSet = null;
|
|
if (element is Wall)
|
|
{
|
|
Wall wall = element as Wall;
|
|
if (!this.IsLegacyCurtainWall(wall))
|
|
{
|
|
CurtainGrid curtainGrid = wall.CurtainGrid;
|
|
curtainGridSet = new CurtainGridSet();
|
|
if (curtainGrid != null)
|
|
{
|
|
curtainGridSet.Insert(curtainGrid);
|
|
}
|
|
}
|
|
}
|
|
else if (element is FootPrintRoof)
|
|
{
|
|
curtainGridSet = (element as FootPrintRoof).CurtainGrids;
|
|
}
|
|
else if (element is ExtrusionRoof)
|
|
{
|
|
curtainGridSet = (element as ExtrusionRoof).CurtainGrids;
|
|
}
|
|
else if (element is CurtainSystem)
|
|
{
|
|
curtainGridSet = (element as CurtainSystem).CurtainGrids;
|
|
}
|
|
return curtainGridSet;
|
|
}
|
|
|
|
// Token: 0x0600007E RID: 126 RVA: 0x0000707C File Offset: 0x0000527C
|
|
private ICollection<ElementId> GetSubElements(CurtainGridSet gridSet)
|
|
{
|
|
HashSet<ElementId> hashSet = new HashSet<ElementId>();
|
|
foreach (object obj in gridSet)
|
|
{
|
|
CurtainGrid curtainGrid = (CurtainGrid)obj;
|
|
hashSet.UnionWith(this.GetVisiblePanelsForGrid(curtainGrid));
|
|
hashSet.UnionWith(curtainGrid.GetMullionIds());
|
|
}
|
|
return hashSet;
|
|
}
|
|
|
|
// Token: 0x0600007F RID: 127 RVA: 0x000070EC File Offset: 0x000052EC
|
|
private ICollection<ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
|
|
{
|
|
ICollection<ElementId> panelIds = curtainGrid.GetPanelIds();
|
|
if (panelIds == null)
|
|
{
|
|
return null;
|
|
}
|
|
HashSet<ElementId> hashSet = new HashSet<ElementId>();
|
|
foreach (ElementId elementId in panelIds)
|
|
{
|
|
Element element = this.doc.GetElement(elementId);
|
|
if (element != null)
|
|
{
|
|
ElementId elementId2 = ElementId.InvalidElementId;
|
|
if (element is Panel)
|
|
{
|
|
elementId2 = (element as Panel).FindHostPanel();
|
|
}
|
|
if (elementId2 != ElementId.InvalidElementId)
|
|
{
|
|
Element element2 = this.doc.GetElement(elementId2);
|
|
if (this._isCurtainSystem(element2))
|
|
{
|
|
CurtainGridSet curtainGridSet = this.GetCurtainGridSet(element2);
|
|
if (curtainGridSet == null || curtainGridSet.Size == 0)
|
|
{
|
|
hashSet.Add(elementId2);
|
|
}
|
|
else
|
|
{
|
|
ICollection<ElementId> subElements = this.GetSubElements(curtainGridSet);
|
|
hashSet.UnionWith(subElements);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hashSet.Add(elementId2);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hashSet.Add(elementId);
|
|
}
|
|
}
|
|
}
|
|
return hashSet;
|
|
}
|
|
|
|
// Token: 0x06000080 RID: 128 RVA: 0x000071EC File Offset: 0x000053EC
|
|
private bool _isCurtainSystem(Element element)
|
|
{
|
|
if (element == null)
|
|
{
|
|
return false;
|
|
}
|
|
CurtainGridSet curtainGridSet = this.GetCurtainGridSet(element);
|
|
if (curtainGridSet == null)
|
|
{
|
|
return element is Wall;
|
|
}
|
|
return curtainGridSet.Size > 0;
|
|
}
|
|
|
|
// Token: 0x06000081 RID: 129 RVA: 0x0000721C File Offset: 0x0000541C
|
|
private bool IsLegacyCurtainWall(Wall wall)
|
|
{
|
|
try
|
|
{
|
|
CurtainGrid curtainGrid = wall.CurtainGrid;
|
|
if (curtainGrid == null)
|
|
{
|
|
return false;
|
|
}
|
|
curtainGrid.GetPanelIds();
|
|
}
|
|
catch (Autodesk.Revit.Exceptions.InvalidOperationException ex)
|
|
{
|
|
if (ex.Message == "The host object is obsolete.")
|
|
{
|
|
return true;
|
|
}
|
|
throw ex;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Token: 0x0400007C RID: 124
|
|
private ParentFinder host;
|
|
|
|
// Token: 0x0400007D RID: 125
|
|
private Document doc;
|
|
}
|
|
}
|