התאמת גודל שרטוט CAD
התאמת גודל שרטוט CAD
Aspose.CAD עבור Java מספק את ההEnumeration הUnitType כדי להתאים את גודל השרטוט במהלך ההמרה של פורמט CAD. ישנן שתי דרכים להתאים את גודל השרטוט.
- התאמת גודל אוטומטית
- התאמת גודל באמצעות הUnitType של מחלקת הcom.aspose.cad.imageoptions
להתאמת גודל אוטומטית, מפתחים אינם צריכים לספק את תכונות הרוחב וגובה של מחלקת הCadRasterizationOptions. בדוגמת קוד שסופקה למטה יש דוגמה של התאמת גודל אוטומטית.
// 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); |
הEnumeration הUnitType מאפשרת להתאים את הסקלה כאשר תכונות הרוחב והגובה אינן מוגדרות. בדוגמת קוד שסופקה למטה מדגימה כיצד להשתמש ב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); |