C#Revit API-如何从Autocad文件中提取信息 [英] C# Revit API - How to pull info from autocad File

查看:590
本文介绍了C#Revit API-如何从Autocad文件中提取信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去一个月,我一直在努力,正在努力建立最终的联系。

I've been working on this for the past month and am trying to get the final connection.

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

so far, I can open Revit, execute an Autocad DLL from a Revit button however I don't know how to pull the information back into the Revit API. I have tried a couple of different methods however I've come to a wall. Here are the options I've tried with explanations below

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

1) Combine the DLL file and the Revit Button API file into one using classes. ---> Trying this method leaves me with an error when loading an existing CAD file. I don't get this error if I'm creating a new CAD file or if I'm running the DLL by itself with Autocad set to Debug.

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

我已经对错误进行了一些研究,这是唯一的解决方法repoo

I've done some research on the error and this is the only close repoo

2)将它们分开
->在此选项中,我了解了如何以编程方式打开AutoCAD,净加载DLL,然后执行它它将获取文件信息,但随后我无法将信息返回给Revit API

2) Keep them separate --> In this option, I've figured out how programatticly open AutoCAD, netload a DLL, and then execute it which grabs the file information but then I cant return the info to the Revit API

对于如何解决此问题,我们深有感激。

Any wisdom or advice is appreciated on how to approach this.

这是我所见过的与此类似的最近帖子,但我认为它在VB中已经超出了我的脑海。
https://forums.autodesk.com/t5/net/system-accessviolationexception-attempted-to-read-or-write/td-p/4796397

this is the closest post i've seen similar to this but its in VB i think and is over my head. https://forums.autodesk.com/t5/net/system-accessviolationexception-attempted-to-read-or-write/td-p/4796397

推荐答案

我认为没有出现这种问题的原因。如果其他所有方法均失败,则可以始终使用IPC分隔两个进程。但是,实际上并不需要这样做。

I see no reason why such a problem should appear. If all else fails, you could always use IPC to separate the two processes. However, there should not really be any need for this.

这篇关于C#Revit API-如何从Autocad文件中提取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆