ส่งออก CAD
ส่งออกภาพ 3D AutoCAD ไปยัง PDF
Aspose.CAD ช่วยให้คุณสามารถส่งออกภาพ 3D AutoCAD ไปยัง PDF ได้ กรุณาใช้ Aspose.CAD.ImageOptions.CadRasterizationOptions เพื่อระบุว่าคุณต้องการส่งออกเอนทิตี 3D
โค้ดตัวอย่างด้านล่างโหลดไฟล์ AutoCAD 3D และส่งออกไปยัง PDF. เมื่ไฟล์ถูกแปลงเป็น PDF คุณสามารถเปิดไฟล์ด้วยโปรแกรมดู PDF ที่คุณชื่นชอบ
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 500; | |
rasterizationOptions.PageHeight = 500; | |
// rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "Export3DImagestoPDF_out.pdf"; | |
cadImage.Save(MyDir, pdfOptions); | |
} |
ส่งออกเลย์เอาต์ CAD ไปยัง PDF
Aspose.CAD สำหรับ .NET ช่วยให้คุณสามารถส่งออกเลย์เอาต์ CAD ไปยัง PDF ได้ โดยใช้ Save เมธอดของ CadImage เพื่อส่งออกเลย์เอาต์ไปยังรูปแบบ PDF
โค้ดตัวอย่างด้านล่างโหลดไฟล์ CAD และส่งออกเลย์เอาต์ “Model” ไปยัง PDF เมื่ไฟล์ถูกแปลงเป็น PDF คุณสามารถเปิดไฟล์ด้วยโปรแกรมดู PDF ที่คุณชื่นชอบ
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
// Create an instance of CadImage class and load the file. | |
using (Aspose.CAD.Image cadImage = (Aspose.CAD.Image)Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of CadRasterizationOptions class | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
// Set the Entities type property to Entities3D. | |
//rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.AutomaticLayoutsScaling = true; | |
rasterizationOptions.NoScaling = false; | |
rasterizationOptions.ContentAsBitmap = true; | |
// Set Layouts | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
// Create an instance of PDF options class | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
MyDir = MyDir + "CADLayoutsToPDF_out.pdf"; | |
// Set Graphics options | |
rasterizationOptions.GraphicsOptions.SmoothingMode = SmoothingMode.HighQuality; | |
rasterizationOptions.GraphicsOptions.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; | |
rasterizationOptions.GraphicsOptions.InterpolationMode = InterpolationMode.HighQualityBicubic; | |
//Export to PDF by calling the Save method | |
cadImage.Save(MyDir, pdfOptions); | |
} |
การสนับสนุนการตั้งค่า Pen ในการส่งออก
Aspose.CAD สำหรับ .NET ช่วยให้คุณสามารถเพิ่มตัวเลือกปากกาลงในคุณสมบัติการส่งออกของ CAD โดยใช้ CadRasterizationOptions เราสามารถตั้งค่าคุณสมบัติของปากกาได้
ด้านล่างนี้เป็นโค้ดตัวอย่างเพื่อให้บรรลุความต้องการที่ระบุ
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
CadImage cadImage = (CadImage)Image.Load(sourceFilePath); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Here user can change default start cap and end cap of pens when exporting CadImage object to | |
// image. It can be using for all image formats: pdf, png, bmp, gif, jpeg2000, jpeg, psd, tiff, wmf. | |
// If user doesn't use PenOptions, system will use its own default pens (different in defferent places). | |
rasterizationOptions.PenOptions = new PenOptions | |
{ | |
StartCap = LineCap.Flat, | |
EndCap = LineCap.Flat | |
}; | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir+"9LHATT-A56_generated.pdf", pdfOptions); | |
การแยกวัตถุ CAD Insert
Aspose.CAD สำหรับ .NET ช่วยให้คุณสามารถแยกวัตถุ CAD และประมวลผลเอนทิตีแยกต่างหากภายใน insert ด้านล่างนี้เป็นโค้ดตัวอย่างเพื่อให้บรรลุความต้องการที่ระบุ
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
for (int i = 0; i < cadImage.Entities.Length; i++) | |
{ | |
if (cadImage.Entities[i].TypeName == CadEntityTypeName.INSERT) | |
{ | |
CadBlockEntity block = cadImage.BlockEntities[(cadImage.Entities[i] as CadInsertObject).Name]; | |
foreach (CadBaseEntity baseEntity in block.Entities) | |
{ | |
// processing of entities | |
} | |
} | |
} |
การสนับสนุนสำหรับ ACAD Proxy Entities
Aspose.CAD สำหรับ .NET ช่วยให้คุณสามารถอ่านและส่งออกเอนทิตี ACAD_PROXY_ENTITY ด้านล่างนี้เป็นโค้ดตัวอย่างเพื่อให้บรรลุความต้องการที่ระบุ
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.UnitType = UnitType.Inch; | |
rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; | |
rasterizationOptions.BackgroundColor = Color.Black; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
cadImage.Save(MyDir+"output.pdf", pdfOptions); | |
} |
รวมฟอร์แมต IGES
Aspose.CAD สำหรับ .NET ช่วยให้คุณสามารถอ่านและส่งออกฟอร์แมต IGES ด้านล่างนี้เป็นโค้ดตัวอย่างเพื่อให้บรรลุความต้องการที่ระบุ
string MyDir = RunExamples.GetDataDir_IGESDrawings(); | |
string sourceFilePath = MyDir + ("figa2.igs"); | |
string outPath = MyDir + ("meshes.pdf"); | |
using (Image igesImage = Image.Load(sourceFilePath)) | |
{ | |
Aspose.CAD.ImageOptions.PdfOptions pdf = new Aspose.CAD.ImageOptions.PdfOptions(); | |
pdf.VectorRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
pdf.VectorRasterizationOptions.PageHeight = 1000; | |
pdf.VectorRasterizationOptions.PageWidth = 1000; | |
igesImage.Save("figa2.pdf", pdf); | |
} |
การสนับสนุนสำหรับโมเดล Mesh
Aspose.CAD สำหรับ .NET ช่วยให้คุณสามารถ implement และนับโมเดล mesh เช่น edges, vertices, และ faces ที่ใช้การแสดงผลแบบพหุนาม ด้านล่างนี้เป็นโค้ดตัวอย่างเพื่อให้บรรลุความต้องการที่ระบุ
string MyDir = RunExamples.GetDataDir_DWGDrawings(); | |
string sourceFilePath = MyDir+("meshes.dwg"); | |
string outPath = MyDir+("meshes.pdf"); | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1600; | |
rasterizationOptions.PageHeight = 1600; | |
//rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; | |
rasterizationOptions.Layouts = new string[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions | |
{ | |
VectorRasterizationOptions = rasterizationOptions | |
}; | |
{ | |
cadImage.Save(outPath, pdfOptions); | |
} | |
} |
ตั้งค่ามุมมองเฉพาะ
Aspose.CAD สำหรับ .NET ช่วยให้คุณสามารถตั้งค่ามุมมองเฉพาะสำหรับเลย์เอาต์โมเดล โดยใช้ VectorRasterizationOptions คุณสามารถตั้งค่ามุมมองเฉพาะได้ โค้ดตัวอย่างด้านล่างแสดงวิธีการตั้งค่ามุมมองเฉพาะ
// The path to the documents directory. | |
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; //Angle of rotation along the X axis | |
float yAngle = 30; //Angle of rotation along the Y axis | |
float zAngle = 40; //Angle of rotation along the Z axis | |
((CadRasterizationOptions)(options.VectorRasterizationOptions)).ObserverPoint = new ObserverPoint(xAngle, yAngle, zAngle); | |
cadImage.Save(outPath, options); | |
} |