123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /*-------------------------------------------------------------------------
- * 功能描述:SharedParameterDefinition
- * 作者:xulisong
- * 创建时间: 2019/3/7 11:14:57
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.Revit.ApplicationServices;
- using Autodesk.Revit.DB;
- namespace FWindSoft.Revit
- {
- public class SharedParameterDefinition
- {
- public const string DefualtGroupName = "共享参数";
- public SharedParameterDefinition():this(DefualtGroupName)
- {
-
- }
- public SharedParameterDefinition(string groupName)
- {
- GroupName = groupName?? DefualtGroupName;
- ParameterType = ParameterType.Text;
- }
- public string GroupName { get; private set; }
- public string Name { get; set; }
- public ParameterType ParameterType { get; set; }
- public bool IsVisible { get; set; } = true;
- public bool UserModify { get; set; } = true;
- /// <summary>
- /// 获取参数定义
- /// </summary>
- /// <param name="application"></param>
- /// <returns></returns>
- public Definition GetDifinition(Application application)
- {
- var file= SharedParameterUtil.GetSharedParameterFile(application);
- var group = file.Groups.get_Item(GroupName);
- if (null == group)
- {
- group = file.Groups.Create(GroupName);
- }
- if (group == null)
- throw new Exception("查找参数分组失败");
- Definition definition = group.Definitions.get_Item(Name);
- if (definition == null)
- {
- var options = SharedParameterUtil.NewDefinitionCreationOptions(Name, ParameterType, true, true);
- definition = SharedParameterUtil.NewDefinition(group,options);
- }
- return definition;
- }
- }
- }
|