Esempio n. 1
0
        /// <summary>
        /// Gets the revit parameter from project info
        /// </summary>
        /// <param name="parameterName">name of the parameter</param>
        /// <returns>parameter or null if not found</returns>
        private Parameter GetParameterFromProjectInfo(string parameterName)
        {
            Element pInfo = _doc.ProjectInformation;

            if (null == pInfo)
            {
                return(null);
            }

            ParameterMap theParamMap = pInfo.ParametersMap;

            if (!theParamMap.Contains(parameterName))
            {
                return(null);
            }

            return(theParamMap.get_Item(parameterName));
        }
Esempio n. 2
0
        public static Parameter GetParameterByDefinitionName(ParameterMap parameterMap, string name)
        {
            if (parameterMap == null)
            {
                Log.WriteLine("Element.ParametersMap is null");
                return(null);
            }
            Parameter result = null;

            if (parameterMap.Contains(name))
            {
                try
                {
                    result = parameterMap.get_Item(name);
                }
                catch (System.Exception value)
                {
                    Log.WriteLine("ParmeterMap contains the key, but can't get it");
                    Log.WriteLine(value);
                }
            }
            return(result);
        }
        void DragParameter(Moment now, ParameterMap other, Parameter p, float value)
        {
            // We have a tiny gutter around 0, since some effects have a sharp step from 0 to anything else and
            // this sounds more jarring if it happens with no tolerance.
            if (value < 0.1f) {
                value = 0;
            }
            // We deliberately use SSA-like structure here to be able to see all the intermediate values in the debugger.
            // First, get the endpoint value of p
            float pValue = p[now.Time];
            // Next, get the base value of p, in normalized terms
            ParameterDescription pDesc = p.Description;
            float pBaseValueNormalized = pDesc.Min == pDesc.Max ? pDesc.Base : (pDesc.Base - pDesc.Min) / (pDesc.Max - pDesc.Min);

            // Now we want to move from pBaseValueNormalized towards pValue, by an amount proportional to dragValue
            float newDestValue = pBaseValueNormalized + ((pValue - pBaseValueNormalized) * value);

            Parameter dest = m_parameters[p.Description];
            if (m_baseParameters.Contains(p.Description)) {
                float baseValue = m_baseParameters[p.Description][now.Time];

                float averagedDestValue = newDestValue;
                if (other != null && other.Contains(p.Description)) {
                    averagedDestValue = (averagedDestValue + other[p.Description][now.Time]) / 2;
                }

                float adjustedDestValue = averagedDestValue;
                if (!p.Description.Absolute) {
                    // only grow upwards from the base value, proportionately to how big the base value already is
                    adjustedDestValue = baseValue + (averagedDestValue * (1 - baseValue));
                }

                Spam.Model.WriteLine("parameter " + p.Description.Name + ": pValue " + pValue + ", pBVN " + pBaseValueNormalized + ", baseValue " + baseValue + ", adjustedDestValue " + adjustedDestValue);

                // clamp to [0, 1] because we may overshoot a bit with this algorithm
                dest[now.Time] = Math.Max(0, Math.Min(1f, adjustedDestValue));
            }
        }