/// <summary>
/// Checks if the element is MEP type.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="element">The element to check.</param>
/// <returns>True for MEP type of elements.</returns>
private bool IsMEPType(ExporterIFC exporterIFC, Element element, IFCExportType exportType)
{
return ElementFilteringUtil.IsMEPType(exportType);
}
/// <summary>
/// Checks if exporting an element as building elment proxy.
/// </summary>
/// <param name="element">The element.</param>
/// <returns>True for exporting as proxy element.</returns>
private bool ExportAsProxy(Element element, IFCExportType exportType)
{
// FaceWall should be exported as IfcWall.
return ((element is FaceWall) || (element is ModelText) || (exportType == IFCExportType.IfcBuildingElementProxy) || (exportType == IFCExportType.IfcBuildingElementProxyType));
}
/// <summary>
/// Exports a family instance as a mapped item.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="familyInstance">
/// The family instance to be exported.
/// </param>
/// <param name="exportType">
/// The export type.
/// </param>
/// <param name="ifcEnumType">
/// The string value represents the IFC type.
/// </param>
/// <param name="wrapper">
/// The ProductWrapper.
/// </param>
/// <param name="overrideLevelId">
/// The level id.
/// </param>
/// <param name="range">
/// The range of this family instance to be exported.
/// </param>
public static void ExportFamilyInstanceAsMappedItem(ExporterIFC exporterIFC,
FamilyInstance familyInstance, IFCExportType exportType, string ifcEnumType,
ProductWrapper wrapper, ElementId overrideLevelId, IFCRange range, IFCAnyHandle parentLocalPlacement)
{
bool exportParts = PartExporter.CanExportParts(familyInstance);
bool isSplit = range != null;
if (exportParts && !PartExporter.CanExportElementInPartExport(familyInstance, isSplit ? overrideLevelId : familyInstance.Level.Id, isSplit))
return;
Document doc = familyInstance.Document;
IFCFile file = exporterIFC.GetFile();
FamilySymbol familySymbol = ExporterIFCUtils.GetOriginalSymbol(familyInstance);
if (familySymbol == null)
return;
ProductWrapper familyProductWrapper = ProductWrapper.Create(wrapper);
double scale = exporterIFC.LinearScale;
Options options = GeometryUtil.GetIFCExportGeometryOptions();
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
HostObject hostElement = familyInstance.Host as HostObject; //hostElement could be null
ElementId categoryId = CategoryUtil.GetSafeCategoryId(familySymbol);
//string emptyString = "";
string familyName = familySymbol.Name;
string objectType = familyName;
// A Family Instance can have its own copy of geometry, or use the symbol's copy with a transform.
// The routine below tells us whether to use the Instance's copy or the Symbol's copy.
bool useInstanceGeometry = ExporterIFCUtils.UsesInstanceGeometry(familyInstance);
IList<IFCExtrusionData> cutPairOpeningsForColumns = new List<IFCExtrusionData>();
using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
{
Transform trf = familyInstance.GetTransform();
// Extra information if we are exporting a door or a window.
IFCDoorWindowInfo doorWindowInfo = null;
if (exportType == IFCExportType.ExportDoorType)
doorWindowInfo = IFCDoorWindowInfo.CreateDoorInfo(exporterIFC, familyInstance, familySymbol, hostElement, overrideLevelId, trf);
else if (exportType == IFCExportType.ExportWindowType)
doorWindowInfo = IFCDoorWindowInfo.CreateWindowInfo(exporterIFC, familyInstance, familySymbol, hostElement, overrideLevelId, trf);
FamilyTypeInfo typeInfo = new FamilyTypeInfo();
XYZ extraOffset = XYZ.Zero;
bool flipped = doorWindowInfo != null ? doorWindowInfo.IsSymbolFlipped : false;
FamilyTypeInfo currentTypeInfo = ExporterCacheManager.TypeObjectsCache.Find(familySymbol.Id, flipped);
bool found = currentTypeInfo.IsValid();
Family family = familySymbol.Family;
// TODO: this code to be removed by ExtrusionAnalyzer code.
bool trySpecialColumnCreation = ((exportType == IFCExportType.ExportColumnType) && (!family.IsInPlace));
IList<GeometryObject> geomObjects = new List<GeometryObject>();
Transform brepOffsetTransform = null;
Transform doorWindowTrf = Transform.Identity;
// We will create a new mapped type if:
// 1. We are exporting part of a column or in-place wall (range != null), OR
// 2. We are using the instance's copy of the geometry (that it, it has unique geometry), OR
// 3. We haven't already created the type.
bool creatingType = ((range != null) || useInstanceGeometry || !found);
if (creatingType)
{
IFCAnyHandle bodyRepresentation = null;
IFCAnyHandle planRepresentation = null;
// If we are using the instance geometry, ignore the transformation.
if (useInstanceGeometry)
trf = Transform.Identity;
// TODO: this code to be removed by ExtrusionAnalyzer code.
if (trySpecialColumnCreation)
//.........这里部分代码省略.........
/// <summary>
/// Checks if export type is distribution control element.
/// </summary>
/// <param name="exportType">
/// The export type.
/// </param>
/// <returns>
/// True if it is distribution control element, false otherwise.
/// </returns>
public static bool IsDistributionControlElementSubType(IFCExportType exportType)
{
return (exportType >= IFCExportType.ExportActuatorType && exportType <= IFCExportType.ExportSensorType);
}
/// <summary>
/// Exports a family instance as standard element.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="element">
/// The element to be exported.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="familyType">
/// The export type.
/// </param>
/// <param name="ifcEnumTypeString">
/// The string value represents the IFC type.
/// </param>
/// <param name="productWrapper">
/// The IFCProductWrapper.
/// </param>
public static bool ExportFamilyInstanceAsStandardElement(IFCExportType familyType)
{
switch (familyType)
{
// These entities don't get exported as a mapped instance. As such, we export them using
// the standard methods.
// standard building elements
case IFCExportType.ExportBeam:
case IFCExportType.ExportCovering:
case IFCExportType.ExportFooting:
case IFCExportType.ExportRailing:
case IFCExportType.ExportRamp:
case IFCExportType.ExportRoof:
case IFCExportType.ExportSlab:
case IFCExportType.ExportStair:
case IFCExportType.ExportWall:
// distribution elements
case IFCExportType.ExportDistributionElement:
case IFCExportType.ExportDistributionControlElement:
case IFCExportType.ExportDistributionFlowElement:
case IFCExportType.ExportEnergyConversionDevice:
case IFCExportType.ExportFlowFitting:
case IFCExportType.ExportFlowMovingDevice:
case IFCExportType.ExportFlowSegment:
case IFCExportType.ExportFlowStorageDevice:
case IFCExportType.ExportFlowTerminal:
case IFCExportType.ExportFlowTreatmentDevice:
case IFCExportType.ExportFlowController:
// furniture elements
case IFCExportType.ExportFurnishingElement:
return true;
default:
return false;
}
}
/// <summary>
/// Exports a family instance as a mapped item.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="familyInstance">
/// The family instance to be exported.
/// </param>
/// <param name="exportType">
/// The export type.
/// </param>
/// <param name="ifcEnumType">
/// The string value represents the IFC type.
/// </param>
/// <param name="wrapper">
/// The IFCProductWrapper.
/// </param>
/// <param name="overrideLevelId">
/// The level id.
/// </param>
/// <param name="range">
/// The range of this family instance to be exported.
/// </param>
public static void ExportFamilyInstanceAsMappedItem(ExporterIFC exporterIFC,
FamilyInstance familyInstance, IFCExportType exportType, string ifcEnumType,
IFCProductWrapper wrapper, ElementId overrideLevelId, UV range)
{
Document doc = familyInstance.Document;
IFCFile file = exporterIFC.GetFile();
FamilySymbol familySymbol = ExporterIFCUtils.GetOriginalSymbol(familyInstance);
if (familySymbol == null)
return;
IFCProductWrapper familyProductWrapper = IFCProductWrapper.Create(wrapper);
double scale = exporterIFC.LinearScale;
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
HostObject hostElement = familyInstance.Host as HostObject; //hostElement could be null
ElementId categoryId = CategoryUtil.GetSafeCategoryId(familySymbol);
//string emptyString = "";
string familyName = familySymbol.Name;
IFCLabel objectType = IFCLabel.Create(familyName);
// A Family Instance can have its own copy of geometry, or use the symbol's copy with a transform.
// The routine below tells us whether to use the Instance's copy or the Symbol's copy.
bool useInstanceGeometry = ExporterIFCUtils.UsesInstanceGeometry(familyInstance);
IList<IFCExtrusionData> cutPairOpeningsForColumns = new List<IFCExtrusionData>();
IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData();
Transform trf = familyInstance.GetTransform();
// Extra information if we are exporting a door or a window.
IFCDoorWindowInfo doorWindowInfo = null;
if (exportType == IFCExportType.ExportDoorType)
doorWindowInfo = IFCDoorWindowInfo.CreateDoorInfo(exporterIFC, familyInstance, familySymbol, hostElement, overrideLevelId, trf);
else if (exportType == IFCExportType.ExportWindowType)
doorWindowInfo = IFCDoorWindowInfo.CreateWindowInfo(exporterIFC, familyInstance, familySymbol, hostElement, overrideLevelId, trf);
IFCTypeInfo typeInfo = new IFCTypeInfo();
XYZ extraOffset = XYZ.Zero;
bool flipped = doorWindowInfo != null ? doorWindowInfo.IsSymbolFlipped : false;
IFCTypeInfo currentTypeInfo = exporterIFC.FindType(familySymbol.Id, flipped);
bool found = currentTypeInfo.IsValid();
Family family = familySymbol.Family;
// TODO: this code to be removed by ExtrusionAnalyzer code.
bool trySpecialColumnCreation = ((exportType == IFCExportType.ExportColumnType) && (!family.IsInPlace));
// We will create a new mapped type if:
// 1. We are exporting part of a column or in-place wall (range != null), OR
// 2. We are using the instance's copy of the geometry (that it, it has unique geometry), OR
// 3. We haven't already created the type.
bool creatingType = ((range != null) || useInstanceGeometry || !found);
if (creatingType)
{
IFCAnyHandle bodyRepresentation = IFCAnyHandle.Create();
IFCAnyHandle planRepresentation = IFCAnyHandle.Create();
// If we are using the instance geometry, ignore the transformation.
if (useInstanceGeometry)
trf = Transform.Identity;
// TODO: this code to be removed by ExtrusionAnalyzer code.
if (trySpecialColumnCreation)
{
XYZ rangeOffset = trf.Origin;
IFCFamilyInstanceExtrusionExportResults results;
if (range != null)
{
results = ExporterIFCUtils.ExportFamilyInstanceAsExtrusion(exporterIFC, familyInstance, useInstanceGeometry, range, overrideLevelId, extraParams);
}
else
{
//.........这里部分代码省略.........
/// <summary>
/// Check if an element assigned to IfcBuildingElementProxy is of MEP Type (by checking its connectors) to enable IfcBuildingElementProxy to take part
/// in the System component and connectivity
/// </summary>
/// <param name="element">The element</param>
/// <param name="exportType">IFC Export Type to check: only for IfcBuildingElementProxy or IfcBuildingElementProxyType</param>
/// <returns></returns>
public static bool ProxyForMEPType(Element element, IFCExportType exportType)
{
if ((exportType == IFCExportType.IfcBuildingElementProxy) || (exportType == IFCExportType.IfcBuildingElementProxyType))
{
try
{
if (element is FamilyInstance)
{
MEPModel m = ((FamilyInstance)element).MEPModel;
if (m != null && m.ConnectorManager != null)
{
return true;
}
}
else
return false;
}
catch
{
}
}
return false;
}
请发表评论