2017-05-08 203 views
0

我想在C#代碼中加載*.api文件。我正在嘗試從Revit文件中導出圖像以用於c#應用程序中的特定視圖。問題是從revit(*.rvt)文件獲取ExternalCommandData。如何使用C#在API中加載Revit文件?

public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit, 
             ref string message, ElementSet elements) 
{ 
    UIApplication uiapp = revit.Application; 
} 

我想瀏覽所有*.rvt文件並從Windows窗體調用上述方法。

回答

0

Revit只能在進程中運行插件,因此無法在WinForm應用程序中使用它的API。您提到的執行方法實際上是由Revit在DLL代碼上調用的。

1

我剛纔已經回答你相應的線程在Revit API討論論壇:

https://forums.autodesk.com/t5/revit-api-forum/how-to-load-revit-file-in-api-using-c/m-p/7071015

直接調用到的Revit API從外部上下文,是而且一直都是非法的。

除非在有效的Revit API上下文中使用Revit API,否則無法使用Revit API。

此類上下文僅由Revit回調方法提供。

您需要訂閱Revit事件,例如外部命令Execute方法。

在事件處理程序中,可以使用Revit API。

您還可以使用Revit API設置可從非Revit-API上下文(例如獨立外部應用程序)引發的外部事件。

這由ModelessDialog/ModelessForm_ExternalEvent Revit SDK示例演示。這裏是所有你需要知道的關於the Revit SDK and getting started with the Revit API

過去,無論是在Revit API討論論壇還是由The Building Coder進行了多次深入的回答和討論,

許多示例和進一步的解釋在Idling and External Events for Modeless Access and Driving Revit from Outside的Building Code主題組中提供。

這裏有一些的Revit API論壇討論線程的處理類似問題:

+0

我在關於此主題的博客文章[外部訪問Revit API]中對我的答案進行了總結和增強(http://thebuildingcoder.typepad.com/blog/2017/05/external-access-to-the- Revit的api.html)。 –

0

如果你想要做的是從RVT或RFA中導出圖像文件,您的需求可能已完全覆蓋Forge。有關詳情和原因的詳細信息,請參閱我的博客文章External Access to the Revit API

相關問題