DGN AutoCADのエクスポート
PDFへのDGN AutoCADフォーマットのエクスポート
Aspose.CAD for .NET APIは、DGN AutoCADファイルを読み込み、PDFフォーマットに変換する機能を提供しました。CadImageクラスがその目的を果たします。
既存のDGNファイルをCadImageとして読み込む必要があります。CadRasterizationOptionsクラスのインスタンスを作成し、さまざまなプロパティを設定します。PdfOptionsクラスのインスタンスを作成し、CadRasterizationOptionsインスタンスを渡します。次に、CadImageクラスのインスタンスのSaveメソッドを呼び出します。
サンプルコード
以下は、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フォーマットのラスタ画像フォーマットへのエクスポート
Aspose.CAD for .NET APIは、DGN AutoCADファイルを読み込み、ラスタ画像に変換する機能を提供しました。CadImageクラスがその目的を果たします。
既存のDGNファイルをCadImageとして読み込む必要があります。CadRasterizationOptionsクラスのインスタンスを作成し、さまざまなプロパティを設定します。JpegOptionsクラスのインスタンスを作成し、CadRasterizationOptionsインスタンスを渡します。次に、CadImageクラスのインスタンスのSaveメソッドを呼び出します。
サンプルコード
以下は、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); | |
} |
DGN v7の3Dエンティティサポート
Aspose.CAD for .NET APIは、DGN AutoCADファイルを読み込み、DGN v7の3Dエンティティをサポートする機能を提供しました。CadImageクラスがその目的を果たします。各DGN画像は9つの事前定義されたビューをサポートしています。これは1から9までの範囲で列挙されます。エクスポート時にビューが定義されていない場合は、マルチページ出力フォーマット(PDFなど)では、すべてのビューがエクスポートされ、それぞれが別のページに配置されます。DGNファイルフォーマットでは3Dエンティティがサポートされており、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); | |
} |