Autodesk.Revit.DB.BuiltInFailures.KeynoteFailures是Revit API中的一部分,包含了与标注关键字相关的失败处理方式。
Autodesk.Revit.DB.BuiltInFailures.KeynoteFailures提供了多种失败处理方式,包括:
可以通过Autodesk.Revit.DB.FailureDefinitionId枚举类型中的成员来获取与标注关键字相关的失败处理方式的FailuerDefinitionId,例如:
var failures = BuiltInFailures.KeynoteFailures;
var annotationAlreadyHasKeynoteId = failures.AnnotationAlreadyHasKeynote;
通过Autodesk.Revit.DB.FailureMessageAccessor.CreateInstance方法创建对应的失败信息实例,例如:
var failureMessage = FailureMessageAccessor.CreateInstance(annotationAlreadyHasKeynoteId);
failureMessage.SetMessageText("标注已经包含了关键字,不能重复添加。");
失败信息实例可以用于在FailureHandler中处理失败,例如:
public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
{
foreach (var failureMessageAccessor in failuresAccessor.GetFailureMessages())
{
if (failureMessageAccessor.GetFailureDefinitionId() == BuiltInFailures.KeynoteFailures.AnnotationAlreadyHasKeynote)
{
failuresAccessor.DeleteWarning(failureMessageAccessor);
}
}
return FailureProcessingResult.Continue;
}