当前位置: 首页>>代码示例>>C#>>正文


C# ProductWrapper.GetElementOfType方法代码示例

本文整理汇总了C#中BIM.IFC.Utility.ProductWrapper.GetElementOfType方法的典型用法代码示例。如果您正苦于以下问题:C# ProductWrapper.GetElementOfType方法的具体用法?C# ProductWrapper.GetElementOfType怎么用?C# ProductWrapper.GetElementOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BIM.IFC.Utility.ProductWrapper的用法示例。


在下文中一共展示了ProductWrapper.GetElementOfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSpaceOccupantInfo

        /// <summary>
        /// Collect information to create space occupants and cache them to create when end export.
        /// </summary>
        /// <param name="exporterIFC">
        /// The exporterIFC object.
        /// </param>
        /// <param name="file">
        /// The IFCFile object.
        /// </param>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        static void CreateSpaceOccupantInfo(ExporterIFC exporterIFC, IFCFile file, Element element, ProductWrapper productWrapper)
        {
            IFCAnyHandle roomHandle = productWrapper.GetElementOfType(IFCEntityType.IfcSpace);

            bool exportToCOBIE = ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE;

            string name;
            if (ParameterUtil.GetStringValueFromElement(element, "Occupant", out name))
            {
                Dictionary<string, IFCAnyHandle> classificationHandles = new Dictionary<string, IFCAnyHandle>();

                // Classifications.
                if (exportToCOBIE)
                {
                    Document doc = element.Document;
                    ProjectInfo projectInfo = doc.ProjectInformation;

                    string location;
                    ParameterUtil.GetStringValueFromElement(projectInfo, "BIM Standards URL", out location);

                    string itemReference;
                    if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Organization ID Reference", out itemReference))
                    {
                        string itemName;
                        ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Organization ID Name", out itemName);

                        IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file,
                          location, itemReference, itemName, null);
                        classificationHandles["Space Occupant Organization ID"] = classificationReference;
                    }

                    if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Sub-Organization ID Reference", out itemReference))
                    {
                        string itemName;
                        ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Sub-Organization ID Name", out itemName);

                        IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file,
                          location, itemReference, itemName, null);
                        classificationHandles["Space Occupant Sub-Organization ID"] = classificationReference;
                    }

                    if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Sub-Organization ID Reference", out itemReference))
                    {
                        string itemName;
                        ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Sub-Organization ID Name", out itemName);

                        IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file,
                          location, itemReference, itemName, null);
                        classificationHandles["Space Occupant Sub-Organization ID"] = classificationReference;
                    }

                    if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Organization Billing ID Reference", out itemReference))
                    {
                        string itemName;
                        ParameterUtil.GetStringValueFromElementOrSymbol(element, "Space Occupant Organization Billing ID Name", out itemName);

                        IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file,
                          location, itemReference, itemName, null);
                        classificationHandles["Space Occupant Organization Billing ID"] = classificationReference;
                    }
                }

                // Look for Parameter Set definition.  We don't use the general approach as Space Occupants are not "real" elements.
                IFCAnyHandle spaceOccupantPSetHnd = CreatePSetSpaceOccupant(exporterIFC, file, element);

                SpaceOccupantInfo spaceOccupantInfo = ExporterCacheManager.SpaceOccupantInfoCache.Find(name);
                if (spaceOccupantInfo == null)
                {
                    spaceOccupantInfo = new SpaceOccupantInfo(roomHandle, classificationHandles, spaceOccupantPSetHnd);
                    ExporterCacheManager.SpaceOccupantInfoCache.Register(name, spaceOccupantInfo);
                }
                else
                {
                    spaceOccupantInfo.RoomHandles.Add(roomHandle);
                    foreach (KeyValuePair<string, IFCAnyHandle> classificationReference in classificationHandles)
                    {
                        if (!spaceOccupantInfo.ClassificationReferences[classificationReference.Key].HasValue)
                            spaceOccupantInfo.ClassificationReferences[classificationReference.Key] = classificationReference.Value;
                        else
                        {
                            // Delete redundant IfcClassificationReference from file.
                            classificationReference.Value.Delete();
                        }
                    }

//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:SpatialElementExporter.cs

示例2: CreateZoneInfos

        /// <summary>
        /// Collect information to create zones and cache them to create when end export.
        /// </summary>
        /// <param name="exporterIFC">
        /// The exporterIFC object.
        /// </param>
        /// <param name="file">
        /// The IFCFile object.
        /// </param>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        static void CreateZoneInfos(ExporterIFC exporterIFC, IFCFile file, Element element, ProductWrapper productWrapper)
        {
            bool exportToCOBIE = ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE;

            // Zone Information - For BCA / GSA
            int val = 0;
            string basePropZoneName = "ZoneName";
            string basePropZoneObjectType = "ZoneObjectType";
            string basePropZoneDescription = "ZoneDescription";

            // While a room may contain multiple zones, only one can have the extra GSA parameters.  We will allow the first zone encountered
            // to be defined by them. If we require defining multiple zones in one room, then the code below should be modified to modify the 
            // names of the shared parameters to include the index of the appropriate room.
            bool exportedExtraZoneInformation = false;

            while (++val < 1000)   // prevent infinite loop.
            {
                string propZoneName, propZoneObjectType, propZoneDescription;
                if (val == 1)
                {
                    propZoneName = basePropZoneName;
                    propZoneObjectType = basePropZoneObjectType;
                    propZoneDescription = basePropZoneDescription;
                }
                else
                {
                    propZoneName = basePropZoneName + " " + val;
                    propZoneObjectType = basePropZoneObjectType + " " + val;
                    propZoneDescription = basePropZoneDescription + " " + val;
                }

                {
                    string zoneName;
                    string zoneObjectType;
                    string zoneDescription;

                    if (ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneName, out zoneName) && !String.IsNullOrEmpty(zoneName))
                    {
                        ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneObjectType, out zoneObjectType);

                        ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneDescription, out zoneDescription);

                        IFCAnyHandle roomHandle = productWrapper.GetElementOfType(IFCEntityType.IfcSpace);

                        Dictionary<string, IFCAnyHandle> classificationHandles = new Dictionary<string, IFCAnyHandle>();
                        IFCAnyHandle energyAnalysisPSetHnd = null;

                        if (exportToCOBIE && !exportedExtraZoneInformation)
                        {
                            bool isSpatialZone = NamingUtil.IsEqualIgnoringCaseAndSpaces(zoneObjectType, "SpatialZone");
                            if (isSpatialZone)
                            {
                                // Classifications.
                                Document doc = element.Document;
                                ProjectInfo projectInfo = doc.ProjectInformation;

                                string location;
                                ParameterUtil.GetStringValueFromElement(projectInfo, "BIM Standards URL", out location);

                                string itemReference;
                                string itemName;
                            
                                // Spatial Zone Type (Owner)
                                if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Type (Owner) Reference", out itemReference))
                                {
                                    ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Type (Owner) Name", out itemName);
                                    
                                    IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file,
                                      location, itemReference, itemName, null);
                                    classificationHandles["Spatial Zone Type (Owner)"] = classificationReference;
                                }

                                // Spatial Zone Security Level (Owner)
                                if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Security Level (Owner) Reference", out itemReference))
                                {
                                    itemName = "";
                                    ParameterUtil.GetStringValueFromElementOrSymbol(element, "Spatial Zone Security Level (Owner) Name", out itemName);

                                    IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file,
                                      location, itemReference, itemName, null);
                                    classificationHandles["Spatial Zone Security Level (Owner)"] = classificationReference;
                                }

                                // Spatial Zone Type (Energy Analysis)
                                if (ParameterUtil.GetStringValueFromElementOrSymbol(element, "ASHRAE Zone Type", out itemName))
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:SpatialElementExporter.cs

示例3: CreateZoneInfos

        /// <summary>
        /// Collect information to create zones and cache them to create when end export.
        /// </summary>
        /// <param name="exporterIFC">The exporterIFC object.</param>
        /// <param name="file">The IFCFile object.</param>
        /// <param name="element">The element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        static void CreateZoneInfos(ExporterIFC exporterIFC, IFCFile file, Element element, ProductWrapper productWrapper)
        {
            bool exportToCOBIE = ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE;

            // Extra zone information, since Revit doesn't have architectural zones.
            int val = 0;
            string basePropZoneName = "ZoneName";
            string basePropZoneObjectType = "ZoneObjectType";
            string basePropZoneDescription = "ZoneDescription";
            string basePropZoneClassificationCode = "ZoneClassificationCode";

            // While a room may contain multiple zones, only one can have the extra parameters.  We will allow the first zone encountered
            // to be defined by them. If we require defining multiple zones in one room, then the code below should be modified to modify the 
            // names of the shared parameters to include the index of the appropriate room.
            bool exportedExtraZoneInformation = false;

            while (++val < 1000)   // prevent infinite loop.
            {
                string propZoneName, propZoneObjectType, propZoneDescription, propZoneClassificationCode;
                if (val == 1)
                {
                    propZoneName = basePropZoneName;
                    propZoneObjectType = basePropZoneObjectType;
                    propZoneDescription = basePropZoneDescription;
                    propZoneClassificationCode = basePropZoneClassificationCode;
                }
                else
                {
                    propZoneName = basePropZoneName + " " + val;
                    propZoneObjectType = basePropZoneObjectType + " " + val;
                    propZoneDescription = basePropZoneDescription + " " + val;
                    propZoneClassificationCode = basePropZoneClassificationCode + " " + val;
                }

                string zoneName;
                string zoneObjectType;
                string zoneDescription;
                string zoneClassificationCode;
                IFCAnyHandle zoneClassificationReference;

                if (ParameterUtil.GetOptionalStringValueFromElementOrSymbol(element, propZoneName, out zoneName) == null)
                    break;

                // If we have an empty zone name, but the value exists, keep looking to make sure there aren't valid values later.
                if (!String.IsNullOrEmpty(zoneName))
                {
                    Dictionary<string, IFCAnyHandle> classificationHandles = new Dictionary<string, IFCAnyHandle>();

                    ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneObjectType, out zoneObjectType);

                    ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneDescription, out zoneDescription);

                    ParameterUtil.GetStringValueFromElementOrSymbol(element, propZoneClassificationCode, out zoneClassificationCode);
                    string classificationName, classificationCode, classificationDescription;

                    if (!String.IsNullOrEmpty(zoneClassificationCode))
                    {
                        ClassificationUtil.ParseClassificationCode(zoneClassificationCode, propZoneClassificationCode, out classificationName, out classificationCode, out classificationDescription);
                        string location = null;
                        ExporterCacheManager.ClassificationLocationCache.TryGetValue(classificationName, out location);
                        zoneClassificationReference = ClassificationUtil.CreateClassificationReference(file, 
                            classificationName, classificationCode, classificationDescription, location);
                        classificationHandles.Add(classificationName, zoneClassificationReference);
                    }

                    IFCAnyHandle roomHandle = productWrapper.GetElementOfType(IFCEntityType.IfcSpace);

                    IFCAnyHandle energyAnalysisPSetHnd = null;

                    if (exportToCOBIE && !exportedExtraZoneInformation)
                    {
                        exportedExtraZoneInformation = CreateGSAInformation(exporterIFC, element, zoneObjectType,
                            classificationHandles, energyAnalysisPSetHnd);
                    }

                    ZoneInfo zoneInfo = ExporterCacheManager.ZoneInfoCache.Find(zoneName);
                    if (zoneInfo == null)
                    {
                        IFCAnyHandle zoneCommonPropertySetHandle = CreateZoneCommonPSet(exporterIFC, file, element);
                        zoneInfo = new ZoneInfo(zoneObjectType, zoneDescription, roomHandle, classificationHandles, energyAnalysisPSetHnd, zoneCommonPropertySetHandle);
                        ExporterCacheManager.ZoneInfoCache.Register(zoneName, zoneInfo);
                    }
                    else
                    {
                        // if description and object type were empty, overwrite.
                        if (!String.IsNullOrEmpty(zoneObjectType) && String.IsNullOrEmpty(zoneInfo.ObjectType))
                            zoneInfo.ObjectType = zoneObjectType;
                        if (!String.IsNullOrEmpty(zoneDescription) && String.IsNullOrEmpty(zoneInfo.Description))
                            zoneInfo.Description = zoneDescription;

                        zoneInfo.RoomHandles.Add(roomHandle);
                        foreach (KeyValuePair<string, IFCAnyHandle> classificationReference in classificationHandles)
                        {
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitIFC,代码行数:101,代码来源:SpatialElementExporter.cs


注:本文中的BIM.IFC.Utility.ProductWrapper.GetElementOfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。