CAD図面サイズの調整
Contents
[
Hide
]Aspose.CAD for .NETライブラリを使用することで、開発者はサポートされている形式への変換中にCAD図面のサイズを調整できます。このトピックでは、UnitType列挙型を使用して、サイズを自動的または手動で調整する方法について説明します。Aspose.CAD.ImageOptionsクラスの。
CAD図面サイズの調整
Aspose.CAD for .NETは、CAD形式の変換中に図面のサイズを調整するためのUnitType列挙型を提供します。図面サイズを調整する方法は2つあります。
- 自動サイズ調整
- Aspose.CAD.ImageOptionsクラスのUnitType列挙型を使用してサイズを調整する
サイズを自動的に調整する場合、開発者はCadRasterizationOptionsクラスのWidthおよびHeightプロパティを提供する必要はありません。以下に示すコードスニペットは、自動サイズ調整の例です。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
// Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} |
UnitType列挙型は、WidthおよびHeightプロパティが設定されていない場合にスケーリングを調整する機能を提供します。以下に示すコードスニペットは、UnitTypeの使用方法を示しています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
// Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} |