Ejemplo n.º 1
0
        private static void GetExpectedWallHeight(Element wall, double value)
        {
            var name   = "Unconnected Height";
            var height = (double)(wall.GetParameterValueByName(name));

            Assert.NotNull(height);
            height.ShouldBeApproximately(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests whether the element has a parameter of a given value.  Returns true if the parameter has an equal value and false otherwise.  A list of parameters names can be given to test against values in elements within parameters.  For example, one can test for a type description from a instance by creating a list of each parameter.  Please note that the comparision is done using the string representation of each parameter.
        /// </summary>
        /// <param name="element">A dynamo wrapped Revit element.</param>
        /// <param name="parameterNames">A list of parameter names.  The parameters in the list will each be retrieved iteratively.  So the first name is on the input element, the next name on the element returned from the first parameter and so on.</param>
        /// <param name="value">A parameter value as a string.</param>
        /// <returns name="Filter">True if the element's parameter equals the input value, otherwise false.</returns>
        //[MultiReturn(new[] { "Filter", "Debug" })]
        //public static Dictionary<string,object> FilterByParameterValue (dynamoElem element, List<string> parameterNames, string value )
        public static bool FilterByParameterValue(DynaElem element, List <string> parameterNames, string value)
        {
            bool   filter;
            object valueParam = element;

            //List<string> debug = new List<string>();

            foreach (string param in parameterNames)
            {
                Type vType = valueParam.GetType();
                //debug.Add("Param Type = " + vType.ToString());

                //if (vType == typeof(dynamoElem))
                //{
                //    dynamoElem e = (dynamoElem)valueParam;
                //    valueParam = e.GetParameterValueByName(param);
                //    debug.Add("Parameter = " + valueParam.ToString());

                //}

                if (vType != typeof(string) && vType != typeof(int) && vType != typeof(double))
                {
                    DynaElem e = (DynaElem)valueParam;
                    valueParam = e.GetParameterValueByName(param);
                    //debug.Add("Parameter = " + valueParam.ToString());
                }
            }

            //debug.Add("Parameter Value = " + valueParam.ToString());
            //debug.Add("Parameter Type = " + valueParam.GetType().ToString());
            //debug.Add("Filter Value = " + value.ToString());
            //debug.Add("Filter Value Type = " + value.GetType().ToString());

            if (value.ToString() == valueParam.ToString())
            {
                filter = true;
            }
            else
            {
                filter = false;
            }

            //debug.Add("Filter Bool = " + filter.ToString());
            //return new Dictionary<string, object>
            //{
            //    { "Filter", filter },
            //    { "Debug",  debug}
            //};
            return(filter);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the listed parameters of an element and returns a Dictionary with the Key being the parameter name and the Value being the parameter value.
        /// </summary>
        /// <param name="element">A Dynamo wrapped element.</param>
        /// <param name="parameterNames">A list of parameter names.</param>
        /// <returns></returns>
        public static synthDict GetParamterToDictionary(DynaElem element, List <string> parameterNames)
        {
            synthDict dict = synthDict.ByEmpty();
            RevitDoc  doc  = element.InternalElement.Document;

            foreach (string name in parameterNames)
            {
                object value = element.GetParameterValueByName(name);
                if (value != null)
                {
                    synthDict.Add(dict, name, value);
                }
            }

            return(dict);
        }