/// <summary> /// Standard static Create function. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="allowRelateToLevel">Whether or not handles are allowed to be related to levels.</param> /// <returns>A new ProductWrapper.</returns> public static ProductWrapper Create(ExporterIFC exporterIFC, bool allowRelateToLevel) { ProductWrapper productWrapper = new ProductWrapper(exporterIFC); productWrapper.m_InternalWrapper = IFCProductWrapper.Create(exporterIFC, allowRelateToLevel); return(productWrapper); }
/// <summary> /// Static Create function for a child wrapper, with a different allowRelateToLevel value. /// </summary> /// <param name="parentWrapper">The parent wrapper.</param> /// <param name="allowRelateToLevel">Whether or not handles are allowed to be related to levels.</param> /// <returns>A new ProductWrapper.</returns> public static ProductWrapper Create(ProductWrapper parentWrapper, bool allowRelateToLevel) { ProductWrapper productWrapper = new ProductWrapper(parentWrapper.m_ExporterIFC); productWrapper.m_InternalWrapper = IFCProductWrapper.Create(parentWrapper.m_InternalWrapper, allowRelateToLevel); productWrapper.m_ParentWrapper = parentWrapper; return(productWrapper); }
/// <summary> /// Static Create function for a child wrapper. /// </summary> /// <param name="parentWrapper">The parent wrapper.</param> /// <returns>A new ProductWrapper.</returns> public static ProductWrapper Create(ProductWrapper parentWrapper) { ProductWrapper productWrapper = new ProductWrapper(parentWrapper.m_ExporterIFC); productWrapper.m_InternalWrapper = IFCProductWrapper.Create(parentWrapper.m_InternalWrapper); productWrapper.m_ParentWrapper = parentWrapper; return(productWrapper); }
/// <summary> /// Export all the parts of the host element. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="hostElement">The host element having parts to export.</param> /// <param name="hostHandle">The host element handle.</param> /// <param name="originalWrapper">The IFCProductWrapper object.</param> public static void ExportHostPart(ExporterIFC exporterIFC, Element hostElement, IFCAnyHandle hostHandle, IFCProductWrapper originalWrapper, IFCPlacementSetter placementSetter, IFCAnyHandle originalPlacement, ElementId overrideLevelId) { using (IFCProductWrapper subWrapper = IFCProductWrapper.Create(exporterIFC, true)) { List <ElementId> associatedPartsList = PartUtils.GetAssociatedParts(hostElement.Document, hostElement.Id, false, true).ToList(); if (associatedPartsList.Count == 0) { return; } bool isWallOrColumn = IsHostWallOrColumn(exporterIFC, hostElement); bool hasOverrideLevel = overrideLevelId != null && overrideLevelId != ElementId.InvalidElementId; IFCExtrusionAxes ifcExtrusionAxes = GetDefaultExtrusionAxesForHost(exporterIFC, hostElement); // Split parts if wall or column is split by level, and then export; otherwise, export parts normally. if (isWallOrColumn && hasOverrideLevel && ExporterCacheManager.ExportOptionsCache.WallAndColumnSplitting) { if (!ExporterCacheManager.HostPartsCache.HasRegistered(hostElement.Id)) { SplitParts(exporterIFC, hostElement, associatedPartsList); // Split parts and associate them with host. } // Find and export the parts that are split by specific level. List <KeyValuePair <Part, IFCRange> > splitPartRangeList = new List <KeyValuePair <Part, IFCRange> >(); splitPartRangeList = ExporterCacheManager.HostPartsCache.Find(hostElement.Id, overrideLevelId); foreach (KeyValuePair <Part, IFCRange> partRange in splitPartRangeList) { PartExporter.ExportPart(exporterIFC, partRange.Key, subWrapper, placementSetter, originalPlacement, partRange.Value, ifcExtrusionAxes, hostElement, overrideLevelId, false); } } else { foreach (ElementId partId in associatedPartsList) { Part part = hostElement.Document.GetElement(partId) as Part; PartExporter.ExportPart(exporterIFC, part, subWrapper, placementSetter, originalPlacement, null, ifcExtrusionAxes, hostElement, overrideLevelId, false); } } // Create the relationship of Host and Parts. ICollection <IFCAnyHandle> relatedElementIds = subWrapper.GetAllObjects(); if (relatedElementIds.Count > 0) { string guid = ExporterIFCUtils.CreateGUID(); HashSet <IFCAnyHandle> relatedElementIdSet = new HashSet <IFCAnyHandle>(relatedElementIds); IFCInstanceExporter.CreateRelAggregates(exporterIFC.GetFile(), guid, exporterIFC.GetOwnerHistoryHandle(), null, null, hostHandle, relatedElementIdSet); } } }
/// <summary> /// Exports curtain object as container. /// </summary> /// <param name="allSubElements"> /// Collection of elements contained in the host curtain element. /// </param> /// <param name="wallElement"> /// The curtain wall element. /// </param> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> public static void ExportCurtainObjectCommonAsContainer(ICollection <ElementId> allSubElements, Element wallElement, ExporterIFC exporterIFC, IFCProductWrapper origWrapper) { if (wallElement == null) { return; } HashSet <ElementId> alreadyVisited = new HashSet <ElementId>(); // just in case. Options geomOptions = GeometryUtil.GetIFCExportGeometryOptions(); { foreach (ElementId subElemId in allSubElements) { using (IFCProductWrapper productWrapper = IFCProductWrapper.Create(origWrapper)) { Element subElem = wallElement.Document.GetElement(subElemId); if (subElem == null) { continue; } GeometryElement geomElem = subElem.get_Geometry(geomOptions); if (geomElem == null) { continue; } if (alreadyVisited.Contains(subElem.Id)) { continue; } alreadyVisited.Add(subElem.Id); try { if (subElem is FamilyInstance) { if (subElem is Mullion) { if (exporterIFC.ExportAs2x2) { ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper); } else { using (IFCPlacementSetter currSetter = IFCPlacementSetter.Create(exporterIFC, wallElement)) { IFCAnyHandle currLocalPlacement = currSetter.GetPlacement(); using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData()) { MullionExporter.Export(exporterIFC, subElem as Mullion, geomElem, currLocalPlacement, extraParams, currSetter, productWrapper); } } } } else { FamilyInstance subFamInst = subElem as FamilyInstance; string ifcEnumType; ElementId catId = CategoryUtil.GetSafeCategoryId(subElem); IFCExportType exportType = ElementFilteringUtil.GetExportTypeFromCategoryId(catId, out ifcEnumType); if (exporterIFC.ExportAs2x2) { if ((exportType == IFCExportType.DontExport) || (exportType == IFCExportType.ExportPlateType) || (exportType == IFCExportType.ExportMemberType)) { exportType = IFCExportType.ExportBuildingElementProxy; } } else { if (exportType == IFCExportType.DontExport) { ifcEnumType = "CURTAIN_PANEL"; exportType = IFCExportType.ExportPlateType; } } FamilyInstanceExporter.ExportFamilyInstanceAsMappedItem(exporterIFC, subFamInst, exportType, ifcEnumType, productWrapper, ElementId.InvalidElementId, null); } } else if (subElem is CurtainGridLine) { ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper); } } catch (Exception ex) { if (ExporterUtil.IsFatalException(wallElement.Document, ex)) { throw ex; } continue; } } } } }
/// <summary> /// Export Curtain Walls and Roofs. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="allSubElements"> /// Collection of elements contained in the host curtain element. /// </param> /// <param name="element"> /// The element to be exported. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> public static void ExportBase(ExporterIFC exporterIFC, ICollection <ElementId> allSubElements, Element element, IFCProductWrapper wrapper) { IFCFile file = exporterIFC.GetFile(); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); IFCPlacementSetter setter = null; using (IFCProductWrapper curtainWallSubWrapper = IFCProductWrapper.Create(wrapper, false)) { try { IFCAnyHandle localPlacement = null; bool canExportCurtainWallAsContainer = CanExportCurtainWallAsContainer(allSubElements, element.Document); IFCAnyHandle rep = null; if (!canExportCurtainWallAsContainer) { setter = IFCPlacementSetter.Create(exporterIFC, element); localPlacement = setter.GetPlacement(); rep = ExportCurtainObjectCommonAsOneBRep(allSubElements, element, exporterIFC, setter, localPlacement); if (IFCAnyHandleUtil.IsNullOrHasNoValue(rep)) { return; } } else { ExportCurtainObjectCommonAsContainer(allSubElements, element, exporterIFC, curtainWallSubWrapper); // This has to go LAST. Why? Because otherwise we apply the level transform twice -- once in the familyTrf, once here. // This will be used just to put the CurtainWall on the right level. setter = IFCPlacementSetter.Create(exporterIFC, element); localPlacement = setter.GetPlacement(); } string objectType = NamingUtil.CreateIFCObjectName(exporterIFC, element); { IFCAnyHandle prodRepHnd = null; IFCAnyHandle elemHnd = null; string elemGUID = ExporterIFCUtils.CreateGUID(element); string elemName = NamingUtil.GetNameOverride(element, exporterIFC.GetName()); string elemDesc = NamingUtil.GetDescriptionOverride(element, null); string elemType = NamingUtil.GetObjectTypeOverride(element, objectType); string elemId = NamingUtil.CreateIFCElementId(element); if (element is Wall || element is CurtainSystem || IsLegacyCurtainElement(element)) { elemHnd = IFCInstanceExporter.CreateCurtainWall(file, elemGUID, ownerHistory, elemName, elemDesc, elemType, localPlacement, prodRepHnd, elemId); } else if (element is RoofBase) { //need to convert the string to enum string ifcEnumType = CategoryUtil.GetIFCEnumTypeName(exporterIFC, element); elemHnd = IFCInstanceExporter.CreateRoof(file, elemGUID, ownerHistory, elemName, elemDesc, elemType, localPlacement, prodRepHnd, elemId, RoofExporter.GetIFCRoofType(ifcEnumType)); } else { return; } if (IFCAnyHandleUtil.IsNullOrHasNoValue(elemHnd)) { return; } wrapper.AddElement(elemHnd, setter, null, true); ExporterIFCUtils.CreateCurtainWallPropertySet(exporterIFC, element, wrapper); PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, wrapper); ICollection <IFCAnyHandle> relatedElementIds = curtainWallSubWrapper.GetAllObjects(); if (relatedElementIds.Count > 0) { string guid = ExporterIFCUtils.CreateSubElementGUID(element, (int)IFCCurtainWallSubElements.RelAggregates); HashSet <IFCAnyHandle> relatedElementIdSet = new HashSet <IFCAnyHandle>(relatedElementIds); IFCInstanceExporter.CreateRelAggregates(file, guid, ownerHistory, null, null, elemHnd, relatedElementIdSet); } exporterIFC.RegisterSpaceBoundingElementHandle(elemHnd, element.Id, ElementId.InvalidElementId); } } finally { if (setter != null) { setter.Dispose(); } } } }