aspose.cad java_【示例详解】AutoCAD处理控件Aspose.CAD 8月新更!支持加载大型DWG文件...

Aspose.CAD for .NET是一个独立的AutoCAD处理API。它提供将DWG,DWF和DXF文件转换为高质量PDF和光栅图像的功能。开发人员可以从AutoCAD文件中选择和转换特定的布局和图层,并轻松跟踪整个文件转换过程。

近期Aspose.CAD for .Net(点击下载)更新至最新版v19.7,新增支持DWG R11,R12格式,增强加载大型CAD文件,支持设置自定义视图以进行渲染,接下来,我们通过示例来了解新增功能!

加载大型DWG文件

Aspose.CAD for .NET提供了使用CadImage类打开非常大的DWG文件的功能。现在,您可以使用下面给出的示例示例轻松打开大文件。

//文档目录的路径.

string MyDir = RunExamples.GetDataDir_DWGDrawings();

string filePathDWG = MyDir + "TestBigFile.dwg";

string filePathFinish = MyDir+ "TestBigFile.dwg.pdf";

Stopwatch stopWatch = new Stopwatch();

try

{

stopWatch.Start();

using (CadImage cadImage = (CadImage)Image.Load(filePathDWG))

{

stopWatch.Stop();

// 将经过的时间作为TimeSpan值获取.

TimeSpan ts = stopWatch.Elapsed;

//格式化并显示TimeSpan值.

string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",

ts.Hours, ts.Minutes, ts.Seconds,

ts.Milliseconds / 10);

Console.WriteLine("RunTime for loading " + elapsedTime);

CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();

rasterizationOptions.PageWidth = 1600;

rasterizationOptions.PageHeight = 1600;

PdfOptions pdfOptions = new PdfOptions();

pdfOptions.VectorRasterizationOptions = rasterizationOptions;

stopWatch = new Stopwatch();

stopWatch.Start();

cadImage.Save(filePathFinish, pdfOptions);

stopWatch.Stop();

//将经过的时间作为TimeSpan值获取.

ts = stopWatch.Elapsed;

//格式化并显示TimeSpan值.

elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",

ts.Hours, ts.Minutes, ts.Seconds,

ts.Milliseconds / 10);

Console.WriteLine("RunTime for converting " + elapsedTime);

}

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

}

设置自定义视图以进行渲染

Aspose.CAD允许您为模型布局设置自定义视点。使用VectorRasterizationOptions可以设置自定义视点。以下示例显示如何设置自定义视点。

//文档目录的路径.

string MyDir = RunExamples.GetDataDir_ConvertingCAD();

string sourceFilePath = MyDir + "conic_pyramid.dxf";

var outPath = Path.Combine(MyDir, "FreePointOfView_out.jpg");

using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath))

{

JpegOptions options = new JpegOptions

{

VectorRasterizationOptions = new CadRasterizationOptions

{

PageWidth = 1500, PageHeight = 1500

}

};

float xAngle = 10; //沿X轴的旋转角度

float yAngle = 30; //沿Y轴的旋转角度

float zAngle = 40; //沿Z轴的旋转角度

((CadRasterizationOptions)(options.VectorRasterizationOptions)).ObserverPoint = new ObserverPoint(xAngle, yAngle, zAngle);

cadImage.Save(outPath, options);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值