Aspose.CAD for .NET是一個獨立的AutoCAD處理API。它提供將DWG,DWF和DXF文件轉換爲高質量PDF和光柵圖像的功能。開發人員能夠從AutoCAD文件中選擇和轉換特定的佈局和圖層,並輕鬆跟蹤整個文件轉換過程。佈局
近期Aspose.CAD for .Net(點擊下載)更新至最新版v19.7,新增支持DWG R11,R12格式,加強加載大型CAD文件,支持設置自定義視圖以進行渲染,接下來,咱們經過示例來了解新增功能!spa
Aspose.CAD for .NET提供了使用CadImage類打開很是大的DWG文件的功能。如今,您能夠使用下面給出的示例示例輕鬆打開大文件。pwa
//文檔目錄的路徑. 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能夠設置自定義視點。如下示例顯示如何設置自定義視點。orm
//文檔目錄的路徑. 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); }