![](/img/trans.png)
[英]How to get FormatProvider from Autodesk.AutoCAD.Geometry.Point3d
[英]How to access AutoCad elements / get xyz coordinates from Autocad
我正在寻找一种使用 Revit API 访问链接的 Autocad 文件的方法。 我已经安装了 SnoopDB,这是一个巨大的帮助。
我发现这也是向前迈出的又一步,但是我无法获得文件的点或线。
我进行了一些探索,发现我能够访问文件名,然后获取 cadlink 的哈希码,但在那之后,我知道如何获取其中的 goemetry。
任何和所有的帮助表示赞赏。
这是我到目前为止所拥有的:
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
Selection sel = uidoc.Selection;
using (Transaction tx = new Transaction(doc))
{
try
{
tx.Start("Tracing Cad");
Reference refer = sel.PickObject(ObjectType.Element, "Select a CAD Link");
Element elem = doc.GetElement(refer);
GeometryElement geoElem = elem.get_Geometry(new Options());
Debug.WriteLine("elem.Category.Name: " + elem.Category.Name); // can grab title of CAD
foreach (GeometryObject geoObj in geoElem)
{
GeometryInstance instance = geoObj as GeometryInstance;
foreach (GeometryObject instObj in instance.SymbolGeometry)
{
Debug.WriteLine("geoObj.GraphicsStyleId: " + geoObj.GraphicsStyleId);
Debug.WriteLine("geoObj.GetHashCode(): " + geoObj.GetHashCode()); // gets hashcode of selected cad link
if (instObj.GetType().Name == "PolyLine")
// if (instObj.GetType().Name == "GeometryInstance")
{
}
else
{
Debug.WriteLine("there are no blocks found in this CAD File");
}
}
}
tx.Commit();
} catch (Exception e )
{
Debug.WriteLine(e.StackTrace);
}
Revit API 不提供对链接的 CAD 文件内部的任何访问。
您所能做的就是执行一些 AutoCAD.NET 代码来读取 DWG 文件本身,前提是您可以访问 DWG 并且安装了 AutoCAD。
Building Coder 分享了一些示例,展示了如何在 Revit 插件中启动 AutoCAD 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.