12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /*-------------------------------------------------------------------------
- * 功能描述:SharedParameterExtension
- * 作者:xulisong
- * 创建时间: 2019/3/7 13:18:15
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using Autodesk.Revit.DB;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FWindSoft.Revit
- {
- public static class SharedParameterExtension
- {
- /// <summary>
- /// 设置共享参数,没有的话进行自动创建
- /// </summary>
- /// <param name="element"></param>
- /// <param name="key"></param>
- /// <param name="value"></param>
- /// <returns></returns>
- public static bool SetSharedParameter(this Element element, string key, string value)
- {
- if (!element.ExistParameter(key))
- {
- SharedParameterDefinition definiton = new SharedParameterDefinition();
- definiton.Name = key;
- var bindingType = element is ElementType;
- var flag= SharedParameterUtil.BindingParameter(element.Document,element.Category, bindingType, definiton.GetDifinition(element.Document.Application));
- if (!flag)
- {
- //绑定参数未成功
- return flag;
- }
- }
- return element.SetParameter(key, value);
- }
- }
- }
|