تعديل حجم رسم CAD
Contents
[
Hide
]باستخدام Aspose.CAD لجافا، يمكن للمطورين ضبط حجم الرسم أثناء تحويل صيغة CAD. تشرح هذه الموضوع الطريقة التي يقوم من خلالها بتعديل الحجم تلقائيًا أو ضبط الحجم باستخدام التعداد UnitType من فئة com.aspose.cad.imageoptions.
تعديل حجم رسم CAD
توفر Aspose.CAD لجافا تعداد UnitType لضبط حجم الرسم أثناء تحويل صيغة CAD. هناك طريقتان لتعديل حجم الرسم.
- تعديل الحجم تلقائيًا
- تعديل الحجم باستخدام تعداد UnitType من فئة com.aspose.cad.imageoptions
لتعديل الحجم تلقائيًا، لا يحتاج المطورون إلى تقديم خصائص العرض والارتفاع من فئة CadRasterizationOptions. الكود المقدم أدناه هو مثال على تعديل الحجم تلقائيًا.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 القدرة على تعديل مقياس عندما لا يتم تعيين خصائص العرض والارتفاع. يوضح الكود المقدم أدناه كيفية استخدام UnitType.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |