コード例 #1
0
ファイル: Elements.cs プロジェクト: andradam75/Synthetic
        /// <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);
        }
コード例 #2
0
ファイル: Elements.cs プロジェクト: andradam75/Synthetic
        /// <summary>
        /// Sets an element's parameters based on a Dictionary object 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="dictionary">A Synthetic Dictionary</param>
        /// <returns></returns>
        public static DynaElem SetParamterByDictionary(DynaElem element, synthDict dictionary)
        {
            RevitDoc doc = element.InternalElement.Document;

            TransactionManager.Instance.EnsureInTransaction(doc);

            foreach (KeyValuePair <string, object> keyValue in synthDict.UnwrapDictionary(dictionary))
            {
                if (element.InternalElement.GetParameters(keyValue.Key)[0].IsReadOnly == false)
                {
                    element.SetParameterByName(keyValue.Key, keyValue.Value);
                }
            }

            TransactionManager.Instance.TransactionTaskDone();

            return(element);
        }