资源简介
基于CADlib 4.0.36.67三方库,可以读写CAD的dwg和dxf文件,将其转换为需要的格式。

代码片段和文件信息
#region (C) Wout Ware 2005-2007
//
// File: DxfExportExample.cs
//
// (c) 2005-2007 Wout Ware All Rights Reserved.
//
#endregion
using System;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using WW.Cad.base;
using WW.Cad.Drawing;
using WW.Cad.Drawing.GDI;
using WW.Cad.IO;
using WW.Cad.Model;
using WW.Math;
namespace DxfExportExample
{
class DxfExportExample
{
public static void Main(string[] args)
{
string format = “pdf“;//输出格式为PDF格式
string filename = “..\\bin\\12.dwg“;//采用相对路径
//“C:\\Users\\Administrator\\Desktop\\12.dwg“;// args[1];
DxfModel model = null;
try {
string extension = Path.GetExtension(filename);
if (string.Compare(extension “.dwg“ true) == 0) {
model = DwgReader.Read(filename);
} else {
model = DxfReader.Read(filename);
}
} catch (Exception e) {
Console.Error.WriteLine(“Error occurred: “ + e.Message);
Environment.Exit(1);
}
string outfile = Path.GetFileNameWithoutExtension(Path.GetFullPath(filename));
Stream stream;
if (format == “pdf“) {
BoundsCalculator boundsCalculator = new BoundsCalculator();
boundsCalculator.GetBounds(model);
Bounds3D bounds = boundsCalculator.Bounds;
PaperSize paperSize = PaperSizes.GetPaperSize(PaperKind.Letter);
// Lengths in inches.
float pageWidth = (float)paperSize.Width / 100f;
float pageHeight = (float)paperSize.Height / 100f;
float margin = 0.5f;
// Scale and transform such that its fits max width/height
// and the top left middle of the cad drawing will match the
// top middle of the pdf page.
// The transform transforms to pdf pixels.
Matrix4D to2DTransform = DxfUtil.GetScaleTransform(
bounds.Corner1
bounds.Corner2
new Point3D(bounds.Center.X bounds.Corner2.Y 0d)
new Point3D(new Vector3D(margin margin 0d) * PdfExporter.InchToPixel)
new Point3D(new Vector3D(pageWidth - margin pageHeight - margin 0d) * PdfExporter.InchToPixel)
new Point3D(new Vector3D(pageWidth / 2d pageHeight - margin 0d) * PdfExporter.InchToPixel)
);
using (stream = File.Create(outfile + “.pdf“)) {
PdfExporter pdfGraphics = new PdfExporter(stream);
pdfGraphics.DrawPage(
model
GraphicsConfig.WhiteBackgroundCorrectForBackColor
to2DTransform
paperSize
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5011 2010-07-10 11:12 DxfExportExampleCS VS2010.csproj
文件 939 2010-07-10 11:10 DxfExportExampleCS VS2010.sln
文件 34494 2008-04-13 18:41 Wout Ware.ico
文件 164248 2019-02-11 08:43 bin\12.dwg
文件 633009 2019-02-11 09:16 bin\12.pdf
文件 42496 2019-02-11 09:18 bin\DxfExportExample.exe
文件 144 2010-07-10 11:12 bin\DxfExportExample.exe.config
文件 13824 2019-02-11 09:18 bin\DxfExportExample.pdb
文件 200704 2011-10-06 12:12 bin\ICSharpCode.SharpZipLib.dll
文件 3073536 2015-11-15 15:21 bin\WW.Cad.dll
文件 4249856 2015-11-13 14:04 bin\WW.Cad.xm
文件 938496 2015-11-15 15:17 bin\WW.dll
文件 84992 2015-11-15 15:15 bin\WW.GL.dll
文件 63457 2015-11-13 14:04 bin\WW.GL.xm
文件 7168 2015-11-15 15:09 bin\WW.License.dll
文件 159232 2015-11-15 14:49 bin\WW.Pdf.dll
文件 208289 2015-11-13 14:04 bin\WW.Pdf.xm
文件 1950668 2015-11-13 14:04 bin\WW.xm
文件 1284 2008-04-13 18:41 Properties\AssemblyInfo.cs
文件 144 2010-07-10 11:12 app.config
文件 5053 2019-02-11 09:20 DxfExportExample.cs
目录 0 2019-02-11 09:20 bin
目录 0 2019-02-11 08:17 Properties
----------- --------- ---------- ----- ----
11837044 23
相关资源
- pscad近海风电模型 Fortran语言
- AutoCAD永久去教育版破解补丁
- railroad铁路CAD生成
- CAD中插入带坐标的正射影像——Inse
- 加密cad图形的lisp文件
- Auto CAD_LISP程序集
- CAD2010注册机32bit and 64bit
- 地下停车场CAD设计图
- 实时显示钢筋标注面积V0.44
- CAD计算板料展开插件
- CAD LISP24个源代码
- CAD剖面图制作LISP程序
- 一个比较完整的开源cad 图形程序
-
ob
jectARX给Auto CAD加工具条 - PSCAD风电建模实例双馈风力发电机的
- Cad坐标转换工具,可进行批量转换
- C读DXF源程序及AutoCAD中的DXF参考文件
- CAD ARX 开发实例
-
AutoCAD ob
jectARX二次开发实例-状态栏 - 机械设计课程设计说明书 (word)
- 在delphi7下进行autocad二次开发的一个简
- shp转cad小工具
- 基于MO实现CAD数据转换为Shape数据后的
- PCAAD7.0教程
- cad边长注记(注记边长(批量).lsp)
- CAD万能字体(~HZTXT.SHX)
- labview 导DXF
- Sentaurus TCAD 中文教程
- AutoCAD v2016 官方.zip
- TtransCAD交通规划详细步骤方法
评论
共有 条评论