การส่งออกฟอร์แมต DGN AutoCAD

การส่งออกฟอร์แมต DGN AutoCAD เป็น PDF

Aspose.CAD สำหรับ .NET API ได้มีการแนะนำฟังก์ชันการทำงานเพื่อโหลดไฟล์ DGN AutoCAD และแปลงเป็นฟอร์แมต PDF คลาส CadImage ทำหน้าที่นี้

คุณต้องโหลดไฟล์ DGN ที่มีอยู่เป็น CadImage สร้างตัวอย่างของคลาส CadRasterizationOptions และตั้งค่าคุณสมบัติต่างๆ สร้างตัวอย่างของคลาส PdfOptions และส่งตัวอย่าง CadRasterizationOptions ไปยังมัน ตอนนี้ให้เรียกใช้เมธอด Save ของตัวอย่างคลาส CadImage

โค้ดตัวอย่าง

ต่อไปนี้คือการสาธิตโค้ดเพื่อแปลง/ส่งออก DGN เป็นฟอร์แมต PDF.

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_DXFDrawings();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath))
{
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.Layouts = new[] { "Model" };
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
cadImage.Save(MyDir + "conic_pyramid.pdf", pdfOptions);
}

การส่งออกฟอร์แมต DGN AutoCAD เป็นฟอร์แมตภาพ Bitmap

Aspose.CAD สำหรับ .NET API ได้มีการแนะนำฟังก์ชันการทำงานเพื่อโหลดไฟล์ DGN AutoCAD และแปลงเป็นภาพ Bitmap คลาส CadImage ทำหน้าที่นี้

คุณต้องโหลดไฟล์ DGN ที่มีอยู่เป็น CadImage สร้างตัวอย่างของคลาส CadRasterizationOptions และตั้งค่าคุณสมบัติต่างๆ สร้างตัวอย่างของคลาส JpegOptions และส่งตัวอย่าง CadRasterizationOptions ไปยังมัน ตอนนี้ให้เรียกใช้เมธอด Save ของตัวอย่างคลาส CadImage

โค้ดตัวอย่าง

ต่อไปนี้คือการสาธิตโค้ดเพื่อแปลง/ส่งออก DGN เป็นภาพ JPEG.

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ExportingDGN();
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn";
// Load an existing DGN file as CadImage.
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an object of DgnRasterizationOptions class and define/set different properties
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = 600;
rasterizationOptions.PageHeight = 300;
rasterizationOptions.NoScaling = true;
rasterizationOptions.AutomaticLayoutsScaling = false;
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it.
Aspose.CAD.ImageOptionsBase options = new Aspose.CAD.ImageOptions.JpegOptions();
options.VectorRasterizationOptions = rasterizationOptions;
// Call the save method of the CadImage class object.
cadImage.Save(MyDir + "ExportDGNToRasterImage_out.pdf", options);
}

การสนับสนุนเอนทิตี 3D สำหรับ DGN v7

Aspose.CAD สำหรับ .NET API ได้มีการแนะนำฟังก์ชันการทำงานเพื่อโหลดไฟล์ DGN AutoCAD และสนับสนุนเอนทิตี 3D สำหรับ DGN v7 คลาส CadImage ทำหน้าที่นี้ ภาพ DGN แต่ละภาพสนับสนุนมุมมองที่กำหนดไว้ล่วงหน้า 9 มุมมอง เรียงลำดับจาก 1 ถึง 9 หากไม่มีการกำหนดมุมมองในการส่งออก สำหรับฟอร์แมตที่มีหลายหน้า (เช่น PDF) มุมมองทั้งหมดจะถูกส่งออก โดยแต่ละหน้าอยู่ในหน้าแยกต่างหาก เอนทิตี 3D ที่สนับสนุนในฟอร์แมตไฟล์ DGN เช่นเดียวกับ 2D สำหรับสิ่งนี้ใช้ VectorRasterizationOptions TypeOfEntities จะไม่ได้รับการใช้อีกต่อไปสำหรับฟอร์แมต DGN (ทั้ง 2D และ 3D สนับสนุนพร้อมกัน)

โค้ดตัวอย่าง

ต่อไปนี้คือโค้ดตัวอย่างเพื่อดูเอนทิตี DGN ที่สนับสนุน

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ExportingDGN();
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn";
string outFile = MyDir + "Nikon_D90_Camera.dgn";
// Load an existing DGN file as CadImage.
using (DgnImage dgnImage = (DgnImage)Image.Load(sourceFilePath))
{
var options = new PdfOptions
{
VectorRasterizationOptions = new CadRasterizationOptions
{
PageWidth = 1500,
PageHeight = 1500,
AutomaticLayoutsScaling = true,
BackgroundColor = Color.Black,
Layouts = new string[] { "1", "2", "3", "9" }//only export 4 (1,2,3 and 9) views
}
};
dgnImage.Save(outFile, options);
}