using Aspose.CAD;
using Aspose.CAD.FileFormats.Cad.CadObjects;
using System.Collections.Generic;
public class FetchEntitiesInViewport
{
public static void Run(string fileName)
{
using (CadImage cadImage = (CadImage)Image.Load(fileName))
{
Dictionary<long, string> layoutBlockHandles = new Dictionary<long, string>();
// Iterate through each layout in the DWG file
foreach (CadLayout layout in cadImage.Layouts.Values)
{
if (layout.BlockTableRecordHandle != null)
{
layoutBlockHandles.Add(layout.BlockTableRecordHandle, layout.LayoutName);
}
}
// Iterate through each entity in the DWG file
foreach (CadEntityBase entity in cadImage.Entities)
{
if (entity.TypeName == CadEntityTypeName.VIEWPORT)
{
// Check if the entity belongs to a layout
if (layoutBlockHandles.ContainsKey(entity.SoftOwner))
{
string layoutName = layoutBlockHandles[entity.SoftOwner];
System.Console.WriteLine($"Layout: {layoutName}, Entity: {entity.TypeName}, Handle: {entity.ObjectHandle}");
}
}
}
}
}
}
I have fetched the viewport of layouts. Now how do i fetch the entities inside the viewport using aspose.cad for dot net