CAD Çizim Boyutunu Ayarlama

CAD çizim boyutunu ayarlama

Aspose.CAD for Java, CAD formatının dönüştürülmesi sırasında çizimin boyutunu ayarlamak için UnitType enumeration’ını sağlar. Çizim boyutunu ayarlamanın iki yolu vardır.

  1. Otomatik boyut ayarlama
  2. com.aspose.cad.imageoptions sınıfının UnitType enumeration’ını kullanarak boyut ayarlama

Boyutun otomatik ayarlanması için, geliştiricilerin CadRasterizationOptions sınıfının Width ve Height özelliklerini sağlaması gerekmez. Aşağıda sağlanan kod parçacığı, otomatik boyutlandırma örneğidir.

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

UnitType enumeration’ı, Width ve Height özellikleri ayarlanmadığında ölçeklemeyi ayarlama yeteneği sağlar. Aşağıda sağlanan kod parçacığı, UnitType‘ın nasıl kullanılacağını gösterir.

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