前言
这个例子介绍如果往族文件里添加参数。
内容
Revit 的参数,参考官方文档:
这个例子的关键接口:
// 通过 FamilyManager 添加参数
FamilyParameter AddParameter(string parameterName, BuiltInParameterGroup parameterGroup, Category familyCategory, bool isInstance);
FamilyParameter AddParameter(string parameterName, BuiltInParameterGroup parameterGroup, ParameterType parameterType, bool isInstance);
FamilyParameter AddParameter(ExternalDefinition familyDefinition, BuiltInParameterGroup parameterGroup, bool isInstance);
如果是共享参数,他的定义存储在外部文件,需要通过 Autodesk.Revit.ApplicationServices.Application
的 DefinitionFile OpenSharedParameterFile()
读取共享参数。从 DefinitionFile
获取 DefinitionGroups
,从 DefinitionGroups
获取 DefinitionGroup
,从 DefinitionGroup
获取 Definitions
。
Autodesk.Revit.DB::Definitions
Autodesk.Revit.DB::ExternalDefinitions
Autodesk.Revit.DB::InternalDefinitions
FamilyParameter
接口:
namespace Autodesk.Revit.DB
{
public class FamilyParameter : APIObject
{
public bool UserModifiable { get; }
public override bool IsReadOnly { get; }
public bool IsShared { get; }
public Guid GUID { get; }
public ElementId Id { get; }
public ParameterSet AssociatedParameters { get; }
public string Formula { get; }
public bool CanAssignFormula { get; }
public bool IsDeterminedByFormula { get; }
public bool IsReporting { get; }
public bool IsInstance { get; }
public StorageType StorageType { get; }
public Definition Definition { get; }
public ForgeTypeId GetUnitTypeId();
}