简体   繁体   English

如何在Revit API中捕获Revit错误?

[英]How do I catch Revit errors in Revit API?

I'm trying to catch an error displayed in Revit to perform some handle operations. 我正在尝试捕获Revit中显示的错误以执行一些句柄操作。 Error is due to the connection of points as shown in the image below. 错误是由于点的连接,如下图所示。 Error image This is what I have tested with so far. 错误图像这是我到目前为止测试过的。

try
{
    var pipe = Pipe.Create(doc, firstPipeType.Id, level.Id, startCon, 
    pathXyz[0]);
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException e)
{
    message = e.Message;
    return Result. Failed;
}

Based on the documentation, I am trying to catch and handle the following exception. 根据文档,我试图捕获并处理以下异常。 "Autodesk.Revit.Exceptions.InvalidOperationException: Thrown when the new pipe fails to connect with the connector." “Autodesk.Revit.Exceptions.InvalidOperationException:当新管道无法与连接器连接时抛出。”

The error message is different from the exception. 错误消息与异常不同。 The instructions on how to handle the error message are provided by The Building Coder in the topic group on Detecting and Handling Dialogues and Failures . 有关如何处理错误消息的说明由Building Coder在“ 检测和处理对话和故障 ”主题组中提供。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM