1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 【示例详解】AutoCAD处理控件Aspose.CAD8月新更!支持加载大型DWG文件

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

时间:2018-12-08 22:48:49

相关推荐

【示例详解】AutoCAD处理控件Aspose.CAD8月新更!支持加载大型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文件的功能。现在,您可以使用下面给出的示例示例轻松打开大文件。

//文档目录的路径.stringMyDir=RunExamples.GetDataDir_DWGDrawings();stringfilePathDWG=MyDir+"TestBigFile.dwg";stringfilePathFinish=MyDir+"TestBigFile.dwg.pdf";StopwatchstopWatch=newStopwatch();try{stopWatch.Start();using(CadImagecadImage=(CadImage)Image.Load(filePathDWG)){stopWatch.Stop();//将经过的时间作为TimeSpan值获取.TimeSpants=stopWatch.Elapsed;//格式化并显示TimeSpan值.stringelapsedTime=String.Format("{0:00}:{1:00}:{2:00}.{3:00}",ts.Hours,ts.Minutes,ts.Seconds,ts.Milliseconds/10);Console.WriteLine("RunTimeforloading"+elapsedTime);CadRasterizationOptionsrasterizationOptions=newCadRasterizationOptions();rasterizationOptions.PageWidth=1600;rasterizationOptions.PageHeight=1600;PdfOptionspdfOptions=newPdfOptions();pdfOptions.VectorRasterizationOptions=rasterizationOptions;stopWatch=newStopwatch();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("RunTimeforconverting"+elapsedTime);}}catch(Exceptionex){Console.WriteLine(ex.Message);}

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

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

//文档目录的路径.stringMyDir=RunExamples.GetDataDir_ConvertingCAD();stringsourceFilePath=MyDir+"conic_pyramid.dxf";varoutPath=bine(MyDir,"FreePointOfView_out.jpg");using(CadImagecadImage=(CadImage)Image.Load(sourceFilePath)){JpegOptionsoptions=newJpegOptions{VectorRasterizationOptions=newCadRasterizationOptions{PageWidth=1500,PageHeight=1500}};floatxAngle=10;//沿X轴的旋转角度floatyAngle=30;//沿Y轴的旋转角度floatzAngle=40;//沿Z轴的旋转角度((CadRasterizationOptions)(options.VectorRasterizationOptions)).ObserverPoint=newObserverPoint(xAngle,yAngle,zAngle);cadImage.Save(outPath,options);}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。