CAD 도면 크기 조정

CAD 도면 크기 조정

Aspose.CAD for Java는 CAD 형식 변환 중 도면 크기를 조정하기 위한 UnitType 열거형을 제공합니다. 도면 크기를 조정하는 방법은 두 가지가 있습니다.

  1. 자동 크기 조정
  2. com.aspose.cad.imageoptions 클래스의 UnitType 열거형을 사용하여 크기 조정

크기를 자동으로 조정하려면 개발자가 CadRasterizationOptions 클래스의 Width 및 Height 속성을 제공할 필요가 없습니다. 아래 제공된 코드 스니펫은 자동 크기 조정의 예입니다.

// 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 열거형은 Width 및 Height 속성이 설정되지 않았을 때 크기를 조정할 수 있는 기능을 제공합니다. 아래 제공된 코드 스니펫은 UnitType을 사용하는 방법을 보여줍니다.

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