Autodesk.Revit.DB.Events.ExternalDataTypeServerFailureResolutionExecutingEventArgs是Revit API中的一个事件参数,用于处理由外部数据类型服务器故障引起的异常情况。
Document
: Document
FailureResolutionData
: FailureResolutionData
RaiseFailureResolutionCompleteEvent(bool)
: void
以下示例展示了如何使用ExternalDataTypeServerFailureResolutionExecutingEventHandler处理事件:
public void Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
// 注册事件处理程序
commandData.Application.FailuresProcessing += new EventHandler<FailuresProcessingEventArgs>(OnFailuresProcessing);
}
catch (Exception ex)
{
message = ex.Message;
return;
}
}
public void OnFailuresProcessing(object sender, FailuresProcessingEventArgs e)
{
// 获取所有与此文档相关的特定类型的故障信息
IList<FailureMessageAccessor> failureMessages = e.GetFailureMessages(FailureSeverity.Error);
foreach (FailureMessageAccessor failureMessage in failureMessages)
{
// 获取外部数据类型故障信息
if (failureMessage.HasResolutionType(typeof(ExternalDataTypeServerFailureResolution)))
{
// 处理故障
ExternalDataTypeServerFailureResolution dataServerResolution = failureMessage.GetResolutionOfType(typeof(ExternalDataTypeServerFailureResolution)) as ExternalDataTypeServerFailureResolution;
ExternalDataTypeServerFailureResolutionExecutingEventArgs args = new ExternalDataTypeServerFailureResolutionExecutingEventArgs(failureMessage.GetFailingElementIds(), dataServerResolution);
args.Document = commandData.Application.ActiveUIDocument.Document;
args.RaiseFailureResolutionCompleteEvent(false);
}
}
}
在此示例中,OnFailuresProcessing事件处理程序获取特定类型的故障信息,并处理外部数据类型故障。通过ExternalDataTypeServerFailureResolutionExecutingEventArgs,在解决故障时触发外部数据类型故障解决完成事件。
Autodesk.Revit.DB.Events.ExternalDataTypeServerFailureResolutionExecutingEventArgs是处理由外部数据类型服务器故障引起的异常情况时非常有用的Revit API类。通过此类参考,您可以了解如何处理故障解决、注册事件处理程序和引发事件。