Beispiel #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="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);
        }
        /// <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;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Cache the parameters for an element, allowing quick access later.
        /// </summary>
        /// <param name="element">The element.</param>
        private static void CacheParametersForElement(Element element)
        {
            if (element == null)
                return;

            ElementId id = element.Id;
            if (m_NonIFCParameters.ContainsKey(id))
                return;

            ParameterElementCache nonIFCParameters = new ParameterElementCache();
            ParameterElementCache ifcParameters = new ParameterElementCache();

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

            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;

                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);

                if (paramDefinition.ParameterGroup != BuiltInParameterGroup.PG_IFC)
                    nonIFCParameters.ParameterCache[cleanPropertyName] = parameter;
                else
                    ifcParameters.ParameterCache[cleanPropertyName] = parameter;
            }
        }
Beispiel #4
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;
                }
            }
        }