How do I obtain the viewport elements of a layout in a dwg file?
@hardp,
please, try if this is useful:
using (CadImage cadImage = (CadImage)Aspose.CAD.Image.Load(fileName))
{
Dictionary<string, string> layoutBlockHandles = new Dictionary<string, string>();
foreach (CadLayout layout in cadImage.Layouts.Values)
{
if (layout.BlockTableRecordHandle != null)
layoutBlockHandles.Add(layout.BlockTableRecordHandle, layout.LayoutName);
}
foreach (CadEntityBase entity in cadImage.Entities)
{
if (entity.TypeName == CadEntityTypeName.VIEWPORT)
{
if (layoutBlockHandles.ContainsKey(entity.SoftOwner))
{
string layoutName = layoutBlockHandles[entity.SoftOwner];
System.Console.WriteLine("Layout: " + layoutName + " entity: " + entity.TypeName + " handle:" + entity.ObjectHandle);
}
}
}
}