Hi,
I am trying to view .dxf file using Aspose.CAD (V 23.1.0) and .net 4.7.1. I am able to read all the layer names from the uploaded dxf file. While adding LayerNames in the rasterizationOptions the code throws an error as follows ```
Index was outside the bounds of the array
I am using below code for the same and execution throws error at highlighted line.
try
{
Aspose.CAD.Live.Demos.UI.Models.License.SetAsposeCADLicense();
// Load an existing CAD document
Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(filename);
// Create an instance of CadRasterizationOptions
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
// Set image width & height
rasterizationOptions.PageWidth = 1024;
rasterizationOptions.PageHeight = 1024;
// Set the drawing to render at the center of image
//rasterizationOptions.CenterDrawing = true;
//rasterizationOptions.TypeOfEntities = Aspose.CAD.ImageOptions.TypeOfEntities.Entities3D;
rasterizationOptions.AutomaticLayoutsScaling = true;
rasterizationOptions.NoScaling = false;
rasterizationOptions.ContentAsBitmap = true;
// Set Graphics options
rasterizationOptions.GraphicsOptions.SmoothingMode = Aspose.CAD.SmoothingMode.HighQuality;
rasterizationOptions.GraphicsOptions.TextRenderingHint = Aspose.CAD.TextRenderingHint.AntiAliasGridFit;
rasterizationOptions.GraphicsOptions.InterpolationMode = Aspose.CAD.InterpolationMode.HighQualityBicubic;
// Get the layers in an instance of CadLayersDictionary
var layersList = image.Layers;
lstOutput.Add(layersList.Count.ToString());
i = 0;
// Iterate over the layers
foreach (var layerName in layersList.GetLayersNames())
{
if (i == currentPage)
{
// Add the layer name to the CadRasterizationOptions's layer list
**rasterizationOptions.Layers[i] = layerName;**
// Create an instance of PngOptions for the resultant image
Aspose.CAD.ImageOptions.JpegOptions options = new Aspose.CAD.ImageOptions.JpegOptions();
// Set rasterization options
options.VectorRasterizationOptions = rasterizationOptions;
image.Save(imagePath, options);
lstOutput.Add(imagePath);
image.Dispose();
break;
}
i++;
}
if (!image.Disposed)
image.Dispose();
}
catch (Exception ex)
{
throw ex;
}