CAD図面サイズの調整

CAD図面サイズの調整

Aspose.CAD for .NETは、CAD形式の変換中に図面のサイズを調整するためのUnitType列挙型を提供します。図面サイズを調整する方法は2つあります。

  1. 自動サイズ調整
  2. Aspose.CAD.ImageOptionsクラスのUnitType列挙型を使用してサイズを調整する

サイズを自動的に調整する場合、開発者はCadRasterizationOptionsクラスのWidthおよびHeightプロパティを提供する必要はありません。以下に示すコードスニペットは、自動サイズ調整の例です。

// 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の使用方法を示しています。

// 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);
}