在 Revit API 中,Autodesk.Revit.DB.FailureResolutionType
类型表示处理 Revit 中发生错误的解决方案类型。该类型常常在 Autodesk.Revit.DB.IFailuresPreprocessor
接口的实现中使用,用于规定如何移除失败(FailureMessage
)。
FailureResolutionType
类型包含如下属性:
RemoveOriginal
可将原始元素删除。FailureResolutionType
类型没有任何方法。
以下示例展示了如何使用 Autodesk.Revit.DB.FailureResolutionType
类型在 Autodesk.Revit.DB.IFailuresPreprocessor
接口的实现中解决失败。
public class MyFailuresPreprocessor : IFailuresPreprocessor
{
public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
{
IList<FailureMessageAccessor> failures = failuresAccessor.GetFailureMessages();
if (failures.Count == 0) return FailureProcessingResult.Continue;
FailureProcessingResult result = FailureProcessingResult.Continue;
foreach (FailureMessageAccessor failure in failures)
{
FailureDefinitionId id = failure.GetFailureDefinitionId();
// 解决指定类型的错误
if (id == BuiltInFailures.PanelScheduleEditFailures_PanelDoesNotExist)
{
// Delete the panel
failure.SetResolutionType(FailureResolutionType.Deleted);
result = FailureProcessingResult.ProceedWithCommit;
}
// 解决其他所有类型的错误
else
{
failure.SetResolutionType(FailureResolutionType.DetectedInUpdate);
result = FailureProcessingResult.Continue;
}
}
return result;
}
}