示例#1
0
        /// <summary>
        /// Gets the parameter by name from an element from the parameter cache.
        /// </summary>
        /// <param name="elementId">The element id.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The Parameter.</returns>
        static private Parameter getParameterByNameFromCache(ElementId elementId, string propertyName)
        {
            Parameter parameter         = null;
            string    cleanPropertyName = NamingUtil.RemoveSpaces(propertyName);

            if (m_IFCParameters[elementId].ParameterCache.TryGetValue(cleanPropertyName, out parameter))
            {
                return(parameter);
            }

            foreach (ParameterElementCache otherCache in m_NonIFCParameters[elementId].Values)
            {
                if (otherCache.ParameterCache.TryGetValue(cleanPropertyName, out parameter))
                {
                    return(parameter);
                }
            }

            return(parameter);
        }
示例#2
0
        /// <summary>
        /// Gets the parameter by name from an element from the parameter cache.
        /// </summary>
        /// <param name="elementId">The element id.</param>
        /// <param name="group">The parameter group.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The Parameter.</returns>
        static private Parameter getParameterByNameFromCache(ElementId elementId, BuiltInParameterGroup group,
                                                             string propertyName)
        {
            Parameter parameter         = null;
            string    cleanPropertyName = NamingUtil.RemoveSpaces(propertyName);

            if (group == BuiltInParameterGroup.PG_IFC)
            {
                m_IFCParameters[elementId].ParameterCache.TryGetValue(cleanPropertyName, out parameter);
                return(null);
            }

            ParameterElementCache otherCache = null;

            m_NonIFCParameters[elementId].TryGetValue(group, out otherCache);
            if (otherCache != null)
            {
                otherCache.ParameterCache.TryGetValue(cleanPropertyName, out parameter);
            }

            return(parameter);
        }
示例#3
0
        /// <summary>
        /// Gets the parameter value by name from the subelement parameter value cache.
        /// </summary>
        /// <param name="elementId">The element id.</param>
        /// <param name="handle">The subelement ifc handle.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The Parameter.</returns>
        static public ParameterValue getParameterValueByNameFromSubelementCache(ElementId elementId, IFCAnyHandle subelementHandle, string propertyName)
        {
            ParameterValue parameterVal      = null;
            string         cleanPropertyName = NamingUtil.RemoveSpaces(propertyName);

            IDictionary <IFCAnyHandle, ParameterValueSubelementCache> anyHandleParamValMap;

            if (!m_SubelementParameterValueCache.TryGetValue(elementId, out anyHandleParamValMap))
            {
                return(parameterVal);
            }

            ParameterValueSubelementCache paramValueCache;

            if (!anyHandleParamValMap.TryGetValue(subelementHandle, out paramValueCache))
            {
                return(parameterVal);
            }


            paramValueCache.ParameterValueCache.TryGetValue(cleanPropertyName, out parameterVal);
            return(parameterVal);
        }
示例#4
0
        /// <summary>
        /// Cache the parameters for an element's subelement (subelementHandle), allowing quick access later.
        /// </summary>
        /// <param name="elementId">The element id.</param>
        /// <param name="subelementHandle">The subelement ifc handle.</param>
        /// <param name="param">The element's parameter that we want to override.</param>
        /// <param name="paramVal">The override value.</param>
        static public void CacheParameterValuesForSubelementHandle(ElementId elementId, IFCAnyHandle subelementHandle, Parameter param, ParameterValue paramVal)
        {
            if ((elementId == ElementId.InvalidElementId) ||
                (subelementHandle == null) ||
                (param == null) ||
                (paramVal == null))
            {
                return;
            }

            if (IsDuplicateParameter(param))
            {
                return;
            }

            Definition paramDefinition = param.Definition;

            if (paramDefinition == null)
            {
                return;
            }

            // Don't cache parameters that aren't visible to the user.
            InternalDefinition internalDefinition = paramDefinition as InternalDefinition;

            if (internalDefinition != null && internalDefinition.Visible == false)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(paramDefinition.Name))
            {
                return;
            }

            string cleanPropertyName = NamingUtil.RemoveSpaces(paramDefinition.Name);

            IDictionary <IFCAnyHandle, ParameterValueSubelementCache> anyHandleParamValMap;

            if (!m_SubelementParameterValueCache.TryGetValue(elementId, out anyHandleParamValMap))
            {
                anyHandleParamValMap = new Dictionary <IFCAnyHandle, ParameterValueSubelementCache>();
                m_SubelementParameterValueCache[elementId] = anyHandleParamValMap;
            }

            ParameterValueSubelementCache paramCache;

            if (!anyHandleParamValMap.TryGetValue(subelementHandle, out paramCache))
            {
                paramCache = new ParameterValueSubelementCache();
                anyHandleParamValMap[subelementHandle] = paramCache;
            }

            ParameterValue cachedParamVal;

            if (paramCache.ParameterValueCache.TryGetValue(cleanPropertyName, out cachedParamVal))
            {
                return;
            }

            paramCache.ParameterValueCache[cleanPropertyName] = paramVal;
        }
示例#5
0
        /// <summary>
        /// Cache the parameters for an element, allowing quick access later.
        /// </summary>
        /// <param name="id">The element id.</param>
        static private void CacheParametersForElement(ElementId id)
        {
            if (id == ElementId.InvalidElementId)
            {
                return;
            }

            if (m_NonIFCParameters.ContainsKey(id))
            {
                return;
            }

            IDictionary <BuiltInParameterGroup, ParameterElementCache> nonIFCParameters = new SortedDictionary <BuiltInParameterGroup, ParameterElementCache>();
            ParameterElementCache ifcParameters = new ParameterElementCache();

            m_NonIFCParameters[id] = nonIFCParameters;
            m_IFCParameters[id]    = ifcParameters;

            Element element = ExporterCacheManager.Document.GetElement(id);

            if (element == null)
            {
                return;
            }

            ParameterSet parameterIds = element.Parameters;

            if (parameterIds.Size == 0)
            {
                return;
            }

            // We will do two passes.  In the first pass, we will look at parameters in the IFC group.
            // In the second pass, we will look at all other groups.
            ParameterSetIterator parameterIt = parameterIds.ForwardIterator();

            while (parameterIt.MoveNext())
            {
                Parameter parameter = parameterIt.Current as Parameter;
                if (parameter == null)
                {
                    continue;
                }

                if (IsDuplicateParameter(parameter))
                {
                    continue;
                }

                Definition paramDefinition = parameter.Definition;
                if (paramDefinition == null)
                {
                    continue;
                }

                // Don't cache parameters that aren't visible to the user.
                InternalDefinition internalDefinition = paramDefinition as InternalDefinition;
                if (internalDefinition != null && internalDefinition.Visible == false)
                {
                    continue;
                }

                if (string.IsNullOrWhiteSpace(paramDefinition.Name))
                {
                    continue;
                }

                string cleanPropertyName = NamingUtil.RemoveSpaces(paramDefinition.Name);

                BuiltInParameterGroup groupId = paramDefinition.ParameterGroup;
                if (groupId != BuiltInParameterGroup.PG_IFC)
                {
                    ParameterElementCache cacheForGroup = null;
                    if (!nonIFCParameters.TryGetValue(groupId, out cacheForGroup))
                    {
                        cacheForGroup             = new ParameterElementCache();
                        nonIFCParameters[groupId] = cacheForGroup;
                    }
                    cacheForGroup.ParameterCache[cleanPropertyName] = parameter;
                }
                else
                {
                    ifcParameters.ParameterCache[cleanPropertyName] = parameter;
                }
            }
        }
示例#6
0
        /// <summary>
        /// Cache the parameters for an element, allowing quick access later.
        /// </summary>
        /// <param name="id">The element id.</param>
        static private void CacheParametersForElement(ElementId id)
        {
            if (id == ElementId.InvalidElementId)
            {
                return;
            }

            if (m_NonIFCParameters.ContainsKey(id))
            {
                return;
            }

            IDictionary <BuiltInParameterGroup, ParameterElementCache> nonIFCParameters = new SortedDictionary <BuiltInParameterGroup, ParameterElementCache>();
            ParameterElementCache ifcParameters = new ParameterElementCache();

            m_NonIFCParameters[id] = nonIFCParameters;
            m_IFCParameters[id]    = ifcParameters;

            Element element = ExporterCacheManager.Document.GetElement(id);

            if (element == null)
            {
                return;
            }

            ParameterSet parameterIds = element.Parameters;

            if (parameterIds.Size == 0)
            {
                return;
            }

            // We will do two passes.  In the first pass, we will look at parameters in the IFC group.
            // In the second pass, we will look at all other groups.
            ParameterSetIterator parameterIt = parameterIds.ForwardIterator();

            while (parameterIt.MoveNext())
            {
                Parameter parameter = parameterIt.Current as Parameter;
                if (parameter == null)
                {
                    continue;
                }

                if (IsDuplicateParameter(parameter))
                {
                    continue;
                }

                Definition paramDefinition = parameter.Definition;
                if (paramDefinition == null)
                {
                    continue;
                }

                // Don't cache parameters that aren't visible to the user.
                InternalDefinition internalDefinition = paramDefinition as InternalDefinition;
                if (internalDefinition != null && internalDefinition.Visible == false)
                {
                    continue;
                }

                if (string.IsNullOrWhiteSpace(paramDefinition.Name))
                {
                    continue;
                }

                string cleanPropertyName = NamingUtil.RemoveSpaces(paramDefinition.Name);

                BuiltInParameterGroup groupId       = paramDefinition.ParameterGroup;
                ParameterElementCache cacheForGroup = null;

                if (groupId != BuiltInParameterGroup.PG_IFC)
                {
                    if (!nonIFCParameters.TryGetValue(groupId, out cacheForGroup))
                    {
                        cacheForGroup             = new ParameterElementCache();
                        nonIFCParameters[groupId] = cacheForGroup;
                    }
                }
                else
                {
                    cacheForGroup = ifcParameters;
                }

                if (cacheForGroup != null)
                {
                    // We may have situations (due to bugs) where a parameter with the same name appears multiple times.
                    // In this case, we will preserve the first parameter with a value.
                    // Note that this can still cause inconsistent behavior in the case where multiple parameters with the same
                    // name have values, and we should warn about that when we start logging.
                    if (!cacheForGroup.ParameterCache.ContainsKey(cleanPropertyName) ||
                        !cacheForGroup.ParameterCache[cleanPropertyName].HasValue)
                    {
                        cacheForGroup.ParameterCache[cleanPropertyName] = parameter;
                    }
                }
            }
        }