繁体   English   中英

C# Revit API - 如何从 autocad 文件中提取信息

[英]C# Revit API - How to pull info from autocad File

过去一个月我一直在努力解决这个问题,并试图获得最终的联系。

到目前为止,我可以打开 Revit,从 Revit 按钮执行 Autocad DLL,但我不知道如何将信息拉回 Revit API。 我尝试了几种不同的方法,但是我遇到了困难。 以下是我尝试过的选项,并在下面进行了解释

1) 使用类将 DLL 文件和 Revit Button API 文件合二为一。 ---> 在加载现有的 CAD 文件时,尝试这种方法会让我出错。 如果我正在创建一个新的 CAD 文件,或者如果我在 Autocad 设置为 Debug 的情况下单独运行 DLL,我不会收到此错误。

Grabbing CAD file failed. 
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
e.StackTrace: 
   at AcDbDatabase.{ctor}(AcDbDatabase* , Boolean , Boolean )
   at Autodesk.AutoCAD.DatabaseServices.Database..ctor(Boolean buildDefaultDrawing, Boolean noDocument)
   at CAD2Revit.AutoCadOperations.grabCAD(String filepath)
   at CAD2Revit.Command.Execute(ExternalCommandData commandData, String& message, ElementSet elements)

尝试运行此行时:

// Create a database and try to load the file
Autodesk.AutoCAD.DatabaseServices.Database db = new Database(false, true); // error occuring here often

我已经对错误进行了一些研究,这是唯一的关闭回购

2) 将它们分开 --> 在这个选项中,我已经弄清楚如何以编程方式打开 AutoCAD,netload 一个 DLL,然后执行它来获取文件信息,但是我无法将信息返回到 Revit API

关于如何解决这个问题的任何智慧或建议表示赞赏。

这是我见过的与此类似的最接近的帖子,但我认为它是在 VB 中编写的,并且超出了我的理解。 https://forums.autodesk.com/t5/net/system-accessviolationexception-attempted-to-read-or-write/td-p/4796397

我看不出为什么会出现这样的问题。 如果所有其他方法都失败了,您始终可以使用 IPC 将两个进程分开 但是,实际上并不需要这样做。

暂无
暂无

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

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