Anpassen der Größe von CAD-Zeichnungen
Contents
[
Hide
]Durch die Verwendung der Aspose.CAD für die .NET-Bibliothek können Entwickler die Größe von CAD-Zeichnungen bei der Konvertierung in ein beliebiges unterstütztes Format anpassen. Dieses Thema erläutert den Ansatz zur automatischen oder manuellen Anpassung der Größe unter Verwendung des UnitType Enums der Aspose.CAD.ImageOptions Klasse.
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.
- Automatische Größenanpassung.
- 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.
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); | |
} |
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.
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); | |
} |