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


C# ProductWrapper.IsEmpty方法代码示例

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


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

示例1: ExportElementProperties

        /// <summary>
        /// Exports the element properties.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="element">The element whose properties are exported.</param>
        /// <param name="productWrapper">The ProductWrapper object.</param>
        private static void ExportElementProperties(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
        {
            if (productWrapper.IsEmpty())
                return;

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                Document doc = element.Document;

                ElementType elemType = doc.GetElement(element.GetTypeId()) as ElementType;

                IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

                ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
                IList<IList<PropertySetDescription>> psetsToCreate = ExporterCacheManager.ParameterCache.PropertySets;

                // In some cases, like multi-story stairs and ramps, we may have the same Pset used for multiple levels.
                // If ifcParams is null, re-use the property set.
                ISet<string> locallyUsedGUIDs = new HashSet<string>();
                IDictionary<Tuple<Element, Element, string>, IFCAnyHandle> createdPropertySets =
                    new Dictionary<Tuple<Element, Element, string>, IFCAnyHandle>();
                IDictionary<IFCAnyHandle, HashSet<IFCAnyHandle>> relDefinesByPropertiesMap =
                    new Dictionary<IFCAnyHandle, HashSet<IFCAnyHandle>>();

                foreach (IFCAnyHandle prodHnd in productSet)
                {
                    IList<PropertySetDescription> currPsetsToCreate = GetCurrPSetsToCreate(prodHnd, psetsToCreate);
                    if (currPsetsToCreate.Count == 0)
                        continue;

                    ElementId overrideElementId = ExporterCacheManager.HandleToElementCache.Find(prodHnd);
                    Element elementToUse = (overrideElementId == ElementId.InvalidElementId) ? element : doc.GetElement(overrideElementId);
                    ElementType elemTypeToUse = (overrideElementId == ElementId.InvalidElementId) ? elemType : doc.GetElement(elementToUse.GetTypeId()) as ElementType;
                    if (elemTypeToUse == null)
                        elemTypeToUse = elemType;

                    IFCExtrusionCreationData ifcParams = productWrapper.FindExtrusionCreationParameters(prodHnd);

                    foreach (PropertySetDescription currDesc in currPsetsToCreate)
                    {
                        // Last conditional check: if the property set comes from a ViewSchedule, check if the element is in the schedule.
                        if (currDesc.ViewScheduleId != ElementId.InvalidElementId)
                            if (!ExporterCacheManager.ViewScheduleElementCache[currDesc.ViewScheduleId].Contains(elementToUse.Id))
                                continue;
                            
                        Tuple<Element, Element, string> propertySetKey = new Tuple<Element, Element, string>(elementToUse, elemTypeToUse, currDesc.Name);
                        IFCAnyHandle propertySet = null;
                        if ((ifcParams != null) || (!createdPropertySets.TryGetValue(propertySetKey, out propertySet)))
                        {
                            HashSet<IFCAnyHandle> props = currDesc.ProcessEntries(file, exporterIFC, ifcParams, elementToUse, elemTypeToUse);
                            if (props.Count > 0)
                            {
                                int subElementIndex = CheckElementTypeValidityForSubIndex(currDesc, prodHnd, element);

                                string guid = GUIDUtil.CreateSubElementGUID(elementToUse, subElementIndex);
                                if (locallyUsedGUIDs.Contains(guid))
                                    guid = GUIDUtil.CreateGUID();
                                else
                                    locallyUsedGUIDs.Add(guid);

                                string paramSetName = currDesc.Name;
                                propertySet = IFCInstanceExporter.CreatePropertySet(file, guid, ownerHistory, paramSetName, null, props);
                                if (ifcParams == null)
                                    createdPropertySets[propertySetKey] = propertySet;
                            }
                        }

                        if (propertySet != null)
                        {
                            IFCAnyHandle prodHndToUse = prodHnd;
                            DescriptionCalculator ifcRDC = currDesc.DescriptionCalculator;
                            if (ifcRDC != null)
                            {
                                IFCAnyHandle overrideHnd = ifcRDC.RedirectDescription(exporterIFC, elementToUse);
                                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(overrideHnd))
                                    prodHndToUse = overrideHnd;
                            }

                            HashSet<IFCAnyHandle> relatedObjects = null;
                            if (!relDefinesByPropertiesMap.TryGetValue(propertySet, out relatedObjects))
                            {
                                relatedObjects = new HashSet<IFCAnyHandle>();
                                relDefinesByPropertiesMap[propertySet] = relatedObjects;
                            }
                            relatedObjects.Add(prodHndToUse);
                        }
                    }
                }

                foreach (KeyValuePair<IFCAnyHandle, HashSet<IFCAnyHandle>> relDefinesByProperties in relDefinesByPropertiesMap)
                {
                    IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null,
                        relDefinesByProperties.Value, relDefinesByProperties.Key);
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:ExporterUtil.cs

示例2: ExportElementClassifications

        private static void ExportElementClassifications(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
        {
            if (productWrapper.IsEmpty())
                return;

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
                foreach (IFCAnyHandle prodHnd in productSet)
                {
                    // No need to check the subtype since Classification can be assigned to IfcRoot
                    // if (IFCAnyHandleUtil.IsSubTypeOf(prodHnd, IFCEntityType.IfcElement))
                    ClassificationUtil.CreateClassification(exporterIFC, file, element, prodHnd);
                }
                transaction.Commit();
            }
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:18,代码来源:ExporterUtil.cs

示例3: ExportElementUniformatClassifications

        /// <summary>Exports the element classification(s)./// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="element">The element whose classifications are exported.</param>
        /// <param name="productWrapper">The ProductWrapper object.</param>
        internal void ExportElementUniformatClassifications(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
        {
            if (productWrapper.IsEmpty())
                return;

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
                foreach (IFCAnyHandle prodHnd in productSet)
                {
                    if (IFCAnyHandleUtil.IsSubTypeOf(prodHnd, IFCEntityType.IfcElement))
                        ClassificationUtil.CreateUniformatClassification(exporterIFC, file, element, prodHnd);
                }
                transaction.Commit();
            }
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:21,代码来源:Exporter.cs

示例4: ExportElementQuantities

        /// <summary>
        /// Exports the IFC element quantities.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="element ">The element whose quantities are exported.</param>
        /// <param name="productWrapper">The ProductWrapper object.</param>
        private static void ExportElementQuantities(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
        {
            if (productWrapper.IsEmpty())
                return;

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                Document doc = element.Document;

                ElementType elemType = doc.GetElement(element.GetTypeId()) as ElementType;

                IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

                ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
                IList<IList<QuantityDescription>> quantitiesToCreate = ExporterCacheManager.ParameterCache.Quantities;

                foreach (IList<QuantityDescription> currStandard in quantitiesToCreate)
                {
                    foreach (QuantityDescription currDesc in currStandard)
                    {
                        foreach (IFCAnyHandle prodHnd in productSet)
                        {
                            if (currDesc.IsAppropriateType(prodHnd))
                            {
                                IFCExtrusionCreationData ifcParams = productWrapper.FindExtrusionCreationParameters(prodHnd);

                                HashSet<IFCAnyHandle> quantities = currDesc.ProcessEntries(file, exporterIFC, ifcParams, element, elemType);

                                if (quantities.Count > 0)
                                {
                                    string paramSetName = currDesc.Name;
                                    string methodName = currDesc.MethodOfMeasurement;

                                    IFCAnyHandle propertySet = IFCInstanceExporter.CreateElementQuantity(file, GUIDUtil.CreateGUID(), ownerHistory, paramSetName, methodName, null, quantities);
                                    IFCAnyHandle prodHndToUse = prodHnd;
                                    DescriptionCalculator ifcRDC = currDesc.DescriptionCalculator;
                                    if (ifcRDC != null)
                                    {
                                        IFCAnyHandle overrideHnd = ifcRDC.RedirectDescription(exporterIFC, element);
                                        if (!IFCAnyHandleUtil.IsNullOrHasNoValue(overrideHnd))
                                            prodHndToUse = overrideHnd;
                                    }
                                    HashSet<IFCAnyHandle> relatedObjects = new HashSet<IFCAnyHandle>();
                                    relatedObjects.Add(prodHndToUse);
                                    IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null, relatedObjects, propertySet);
                                }
                            }
                        }
                    }
                }
                transaction.Commit();
            }
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:60,代码来源:ExporterUtil.cs

示例5: ExportElementProperties

        /// <summary>
        /// Exports the element properties.
        /// </summary>
        /// <param name="exporterIFC">The IFC exporter object.</param>
        /// <param name="element">The element whose properties are exported.</param>
        /// <param name="productWrapper">The ProductWrapper object.</param>
        public void ExportElementProperties(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
        {
            if (productWrapper.IsEmpty())
                return;

            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                Document doc = element.Document;

                ElementType elemType = doc.GetElement(element.GetTypeId()) as ElementType;

                IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();

                ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
                IList<IList<PropertySetDescription>> psetsToCreate = ExporterCacheManager.ParameterCache.PropertySets;

                foreach (IFCAnyHandle prodHnd in productSet)
                {
                    IList<PropertySetDescription> currPsetsToCreate = GetCurrPSetsToCreate(prodHnd, psetsToCreate);
                    if (currPsetsToCreate.Count == 0)
                        continue;

                    ElementId overrideElementId = ExporterCacheManager.HandleToElementCache.Find(prodHnd);
                    Element elementToUse = (overrideElementId == ElementId.InvalidElementId) ? element : doc.GetElement(overrideElementId);
                    ElementType elemTypeToUse = (overrideElementId == ElementId.InvalidElementId) ? elemType : doc.GetElement(elementToUse.GetTypeId()) as ElementType;
                    if (elemTypeToUse == null)
                        elemTypeToUse = elemType;

                    IFCExtrusionCreationData ifcParams = productWrapper.FindExtrusionCreationParameters(prodHnd);

                    foreach (PropertySetDescription currDesc in currPsetsToCreate)
                    {
                        HashSet<IFCAnyHandle> props = currDesc.ProcessEntries(file, exporterIFC, ifcParams, elementToUse, elemTypeToUse);
                        if (props.Count > 0)
                        {
                            int subElementIndex = CheckElementTypeValidityForSubIndex(currDesc, prodHnd, element);

                            string guid = null;
                            if (subElementIndex > 0)
                            {
                                guid = ExporterIFCUtils.CreateSubElementGUID(elementToUse, subElementIndex);
                            }
                            else
                            {
                                guid = ExporterIFCUtils.CreateGUID();
                            }

                            string paramSetName = currDesc.Name;
                            IFCAnyHandle propertySet = IFCInstanceExporter.CreatePropertySet(file, guid, ownerHistory, paramSetName, null, props);
                            IFCAnyHandle prodHndToUse = prodHnd;
                            DescriptionCalculator ifcRDC = currDesc.DescriptionCalculator;
                            if (ifcRDC != null)
                            {
                                IFCAnyHandle overrideHnd = ifcRDC.RedirectDescription(exporterIFC, elementToUse);
                                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(overrideHnd))
                                    prodHndToUse = overrideHnd;
                            }
                            HashSet<IFCAnyHandle> relatedObjects = new HashSet<IFCAnyHandle>();
                            relatedObjects.Add(prodHndToUse);
                            IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null, relatedObjects, propertySet);
                        }
                    }
                }
                transaction.Commit();
            }

            if (exporterIFC.ExportAs2x2)
                ExportPsetDraughtingFor2x2(exporterIFC, element, productWrapper);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:76,代码来源:Exporter.cs


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