Het aanpassen van de CAD-tekeninggrootte

Het aanpassen van de CAD-tekeninggrootte

Aspose.CAD voor Java biedt de UnitType enumeratie om de grootte van de tekening aan te passen tijdens de conversie van het CAD-formaat. Er zijn twee manieren om de tekeningsgrootte aan te passen.

  1. Automatisch de grootte aanpassen
  2. De grootte aanpassen met behulp van de UnitType enumeratie van de com.aspose.cad.imageoptions klasse

Voor automatisch aanpassen van de grootte hoeven ontwikkelaars de eigenschappen Breedte en Hoogte van de CadRasterizationOptions klasse niet op te geven. Hieronder staat een codefragment als voorbeeld van automatische sizing.

// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java
// Path to source file
String sourceFilePath = "sample.dwg";
// Load a CAD drawing in an instance of Image
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("sourceFilePath");
// Create an instance of BmpOptions class
com.aspose.cad.imageoptions.BmpOptions bmpOptions = new com.aspose.cad.imageoptions.BmpOptions();
// Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions cadRasterizationOptions =
new com.aspose.cad.imageoptions.CadRasterizationOptions();
bmpOptions.setVectorRasterizationOptions(cadRasterizationOptions);
cadRasterizationOptions.setCenterDrawing(true);
// Set the layouts property
cadRasterizationOptions.setLayouts( new String[] { "Model" } );
// Export layout to BMP format
String outPath = sourceFilePath + ".bmp";
objImage.save(outPath, bmpOptions);

De UnitType enumeratie geeft de mogelijkheid om de schaal aan te passen wanneer de eigenschappen Breedte en Hoogte niet zijn ingesteld. Hieronder staat een codefragment dat demonstreert hoe u UnitType kunt gebruiken.

String dataDir = Utils.getDataDir(AdjustingCADDrawingSizeUsingUnitType.class) + "CADConversion/";
// Path to source file
String sourceFilePath = dataDir + "sample.dwg";
// Load a CAD drawing in an instance of Image
Image image = Image.load(sourceFilePath);
// Create an instance of BmpOptions class
com.aspose.cad.imageoptions.BmpOptions bmpOptions = new com.aspose.cad.imageoptions.BmpOptions();
// Create an instance of CadRasterizationOptions and set its various properties
com.aspose.cad.imageoptions.CadRasterizationOptions cadRasterizationOptions =
new com.aspose.cad.imageoptions.CadRasterizationOptions();
bmpOptions.setVectorRasterizationOptions(cadRasterizationOptions);
// Set the UnitType property
cadRasterizationOptions.setUnitType(com.aspose.cad.imageoptions.UnitType.Centimenter);
// Set the layouts property
cadRasterizationOptions.setLayouts( new String[] { "Model" } );
// Export layout to BMP format
String outPath = sourceFilePath + ".bmp";
image.save(outPath, bmpOptions);