/*-------------------------------------------------------------------------
* 功能描述: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
{
///
/// 设置共享参数,没有的话进行自动创建
///
///
///
///
///
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);
}
}
}