Anpassen der Größe von CAD-Zeichnungen

Anpassen der Größe von CAD-Zeichnungen

Aspose.CAD für .NET bietet die UnitType Aufzählung, um die Größe der Zeichnung während der Konvertierung des CAD-Formats anzupassen. Es gibt zwei Möglichkeiten, die Zeichnungsgröße anzupassen.

  1. Automatische Größenanpassung.
  2. Größe anpassen unter Verwendung der UnitType Aufzählung der Aspose.CAD.ImageOptions Klasse

Für eine automatische Anpassung der Größe müssen Entwickler nicht die Breiten- und Höhen-Eigenschaften der CadRasterizationOptions Klasse angeben. Der unten bereitgestellte Codeausschnitt ist ein Beispiel für die automatische Größenanpassung.

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

Die UnitType Aufzählung ermöglicht eine Anpassung der Skalierung, wenn die Breiten- und Höhen-Eigenschaften nicht festgelegt sind. Der unten bereitgestellte Codeausschnitt zeigt, wie man UnitType verwendet.

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