使用Java读取Dxf文件
我正在尝试在 Java 中编写/查找一些代码,这些代码读取 dxf 文件并将几何图形从“实体”部分存储到数组中,以便稍后可以将该信息以表的形式导入到 Oracle 11g 中。
先感谢您!
I am trying to write/find some code in Java which reads dxf files and stores geometry from the "Entities" section into arrays so that I can later import that information into Oracle 11g in terms of tables.
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最近使用过 kabeja 并且没有遇到任何问题,尽管我做了非常简单的任务。如果您只想将这些几何图形放入数组中,它就可以完成这项工作(在其他情况下我无法告诉)。
如果您已经了解 DXF 格式,那么上手就不会有任何问题。它可以像下面这样简单(例如提取一些圆形实体):
文档有点不完整,但它有不错的 javadocs 和干净的 api。
I've used kabeja recently and haven´t had any problems, though I did quite simple tasks. If you just want to bring those geometries into an array it will do the job (in other cases I can't tell).
If you already know the DXF format you will have no problems to get started. It can get as easy as follows (e.g. to extract some circle entities):
The documentation is a bit incomplete, but it has decent javadocs and clean api.
对于一些普遍感兴趣的反馈,请阅读读取 .DXF 文件
有许多实现 DXF 阅读器的 Java 库/writer 像 kabeja (开源)和 de-caff(免费查看器,它所基于的库可在商业上获得)。
警告:DXF 比乍一看要复杂得多,因此,如果您选择一个解决方案,请在您的数据上对其进行彻底测试。
For some feedback of general interest read Reading .DXF files
There's a number of Java libraries that implement a DXF reader/writer like kabeja (Open Source) and de-caff (a free viewer, the libraries it's based on are available commercially).
A word of warning: DXF is way more complicated than it looks at first sight, so if you select a solution test it thoroughly on your data.
我在我的项目中使用了 Kabeja ,我注意到它是一个非常好的选择,因为它是一个免费且功能强大的工具。
AutoCAD 线由两个末端(起点和终点)表示,
每个点有 3 个坐标:
X
、Y
和Z
下面是2D 方法(适用于
X
和Y
),将 dxf 文件作为参数,对其进行解析,然后提取其中的行。AutoCAD 行将使用 kabeja 函数读取,然后我们可以构建自己的 Java
Line
,其中每个
Line
大约是两个 Java 演示中的点:
Line
的 ArrayList 包含所有autocad 文件的行,我们可以示例在JPanel
上绘制这个数组列表,这样我们就可以从 autocad 完全迁移到 Java。I have used Kabeja in my project and I noticed that it is a very good choice because it is a free and powerful tool.
A autocad line is represented by two extremities (the start and the end point)
Each point has 3 coordinates :
X
,Y
andZ
Below is a 2D method (working on both
X
andY
) that takes a dxf file as parameter, parse it and then extracts the lines inside it.The autocad lines will be readed using kabeja functions, then we can build our own Java
Line
sWhere each
Line
is about two Points in JavaDemo:
The ArrayList of
Line
s contains all the lines of the autocad file, we can per example draw this arraylist on aJPanel
so in this way we are migrating completely from autocad to Java.