Java库以编程方式将AutoCAD .dwg文件转换为PDF或图像?

时间:2015-08-13 09:50:38

标签: autocad dwg

是否存在将.dwg文件直接转换为PDF或图像文件的Java库(免费和开源)? .dwg使用CAD的最新规范(R14,R13,R12和2013)。

我知道.NET和C ++中有一些...... Java中的一些主要是专有且昂贵的(例如:Teigha for Java)。

Java中的免费软件如Kabeja通过中间格式.dxf,这是一个非常庞大的文件......

2 个答案:

答案 0 :(得分:5)

不确定库,但您当然可以使用AutoCAD I / O,它是作为Web服务运行的AutoCAD,无需在您的计算机上运行任何应用程序。请点击http://developer.autodesk.com

了解更多信息

这是一个脚本(.scr),您可以在AutoCAD Console上使用该脚本来创建PDF文件。在这里工作得很好。

(setq CurrDwgName (getvar "dwgname"))
(setq Fname (substr CurrDwgName 1 (- (strlen CurrDwgName) 4)))
(setq name (strcat (getvar "DWGPREFIX") Fname ".pdf"))
;Command:
FILEDIA
;Enter new value for FILEDIA <1>:
0
;Command:
-PLOT
;Detailed plot configuration? [Yes/No] <No>: 
Yes
;Enter a layout name or [?] <Model>:
Model
;Enter an output device name or [?] <None>:
DWG To PDF.pc3
;Enter paper size or [?] <ANSI A (11.00 x 8.50 Inches)>:
ANSI A (11.00 x 8.50 Inches)
;Enter paper units [Inches/Millimeters] <Inches>:
Inches
;Enter drawing orientation [Portrait/Landscape] <Portrait>: 
Landscape
;Plot upside down? [Yes/No] <No>:
No
;Enter plot area [Display/Extents/Limits/View/Window] <Display>: 
Extents
;Enter plot scale (Plotted Inches=Drawing Units) or [Fit] <Fit>:
Fit
;Enter plot offset (x,y) or [Center] <0.00,0.00>:

;Plot with plot styles? [Yes/No] <Yes>:
Yes
;Enter plot style table name or [?] (enter . for none) <>:
.
;Plot with lineweights? [Yes/No] <Yes>:
Yes
;Enter shade plot setting [As displayed/legacy Wireframe/legacy Hidden/Visualstyles/Rendered] <As displayed>:

;Enter file name <C:\Work\solids-Model.pdf>:
!name
;Save changes to page setup? Or set shade plot quality? [Yes/No/Quality] <N>:
No
;Proceed with plot [Yes/No] <Y>:
Yes
;Command:
FILEDIA
;;;Enter new value for FILEDIA <1>:
1 

如果您感觉像'老派',请创建一个.BAT文件:

FOR %%f IN (C:\dwg_folder\*.dwg) DO "C:\Program Files\Autodesk\AutoCAD 2016\accoreconsole.exe" /i "%%f"  /product ACAD /s "C:\folder\PDFScript.scr" /l en-US

这应该批量处理特定文件夹中的所有DWG到PDF

答案 1 :(得分:2)

截至2015年:

经过不断的研究和测试,我得出结论,目前没有免费的解决方案可以将AutoCAD .dwg文件转换为PDF格式的PDF /图像,我们可以认为这是可靠的。这尤其适用于最新版本的AutoCAD,例如:AutoCAD 2010,AutoCAD 2013等....

可靠(且价格昂贵)的解决方案将是ODA的Teigha(每年2000美元)和AutoCAD的C#中的RealDWG(每年5000美元)......

更便宜的替代品是这样的:

  • AutoCAD I / O每月10美元(由Augusto Gonclaves建议)
  • 编写LISPS例程并在AutoCAD 2015/2016的付费实例中使用SCRIPT文件运行它们。
  • 等待更完整的AutoCAD Core Console实施......

Kabeja和YCad等开源库可能能够处理较旧的AutoCAD版本,但对它们的期望不高,因为几年前这些项目处于非活动状态。值得关注的是Apache Tika,因为他们开始为.dwg文件编写解析器,但开发速度很慢......