在族环境中获取当前族的所有族类型以及族类型对应的所有参数和参数值。直接上代码~
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var doc = commandData.Application.ActiveUIDocument.Document;
if (!doc.IsFamilyDocument)
{
return Result.Cancelled;
}
var familyManager = doc.FamilyManager;
var familyTypesItor = familyManager.Types.ForwardIterator();
familyTypesItor.Reset();
var parameters = familyManager.GetParameters();
var strBuilder = new StringBuilder();
while (familyTypesItor.MoveNext())
{
var familyType = familyTypesItor.Current as FamilyType;
strBuilder.AppendLine($"Type name:{familyType.Name}");
foreach (var parameter in parameters)
{
object value = null;
switch (parameter.StorageType)
{
case StorageType.Integer:
value = familyType.AsInteger(parameter);
break;
case StorageType.Double:
value = familyType.AsDouble(parameter) * 304.8;
break;
case StorageType.String:
value = familyType.AsString(parameter);
break;
case StorageType.ElementId:
value = familyType.AsElementId(parameter);
break;
}
strBuilder.AppendLine($"Parameter name :{parameter.Definition.Name},StorageType:{parameter.StorageType},Parameter Value:{value}");
}
strBuilder.AppendLine();
}
TaskDialog.Show("Revit", strBuilder.ToString());
return Result.Succeeded;
}
标签:StorageType,value,参数值,strBuilder,var,familyType,二次开发,parameter,Revit From: https://www.cnblogs.com/youngala/p/17591457.html