示例#1
0
        /// <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();
                    }
                }
            }
        }