Ajustar el tamaño del dibujo CAD
Ajustar el tamaño del dibujo CAD
Aspose.CAD para .NET proporciona la enumeración UnitType para ajustar el tamaño del dibujo durante la conversión del formato CAD. Hay dos formas de ajustar el tamaño del dibujo.
- Ajuste de tamaño automático.
- Ajustar el tamaño utilizando la enumeración UnitType de la clase Aspose.CAD.ImageOptions.
Para ajustar automáticamente el tamaño, los desarrolladores no necesitan proporcionar las propiedades Width y Height de la clase CadRasterizationOptions. El siguiente fragmento de código proporcionado es un ejemplo de ajuste automático.
// 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); | |
} |
La enumeración UnitType proporciona la capacidad de ajustar la escala cuando no se establecen las propiedades Width y Height. El siguiente fragmento de código proporcionado demuestra cómo usar 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); | |
} |