ضبط حجم رسم CAD
ضبط حجم رسم CAD
توفر Aspose.CAD لـ .NET التعداد UnitType لضبط حجم الرسم أثناء تحويل تنسيق CAD. هناك طريقتان لضبط حجم الرسم.
- ضبط الحجم تلقائيًا.
- ضبط الحجم باستخدام التعداد UnitType لفئة Aspose.CAD.ImageOptions.
لضبط الحجم تلقائيًا، لا يحتاج المطورون إلى توفير خصائص العرض والارتفاع لفئة CadRasterizationOptions. الكود المقدم أدناه هو مثال على ضبط الحجم تلقائيًا.
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
// Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} |
التعداد UnitType يعطي القدرة على ضبط القياس عندما لا يتم تعيين خصائص العرض والارتفاع. الكود المقدم أدناه يوضح كيفية استخدام UnitType.
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET | |
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ConvertingCAD(); | |
string sourceFilePath = MyDir + "sample.dwg"; | |
// Load a CAD drawing in an instance of Image | |
using (var image = Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an instance of BmpOptions class | |
Aspose.CAD.ImageOptions.BmpOptions bmpOptions = new Aspose.CAD.ImageOptions.BmpOptions(); | |
// Create an instance of CadRasterizationOptions and set its various properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
bmpOptions.VectorRasterizationOptions = cadRasterizationOptions; | |
// Set the UnitType property | |
cadRasterizationOptions.UnitType = Aspose.CAD.ImageOptions.UnitType.Centimenter; | |
// Set the layouts property | |
cadRasterizationOptions.Layouts = new string[] { "Model" }; | |
// Export layout to BMP format | |
string outPath = sourceFilePath + ".bmp"; | |
image.Save(outPath, bmpOptions); | |
} |