How to get CAD layers and layouts

GroupDocs.Viewer provides additional information about CAD drawings such as list of layouts and layers when calling GetViewInfo method. To retrieve view information for CAD drawing call GetViewInfo method and cast output result to CadViewInfo type.

Following example demonstrates how to retrieve view information for CAD drawing.

using (Viewer viewer = new Viewer("sample.dwg"))
{
    ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
    CadViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions) as CadViewInfo;

    Console.WriteLine("File type: " + viewInfo.FileType);
    Console.WriteLine("Pages count: " + viewInfo.Pages.Count);

    foreach (Layout layout in viewInfo.Layouts)
        Console.WriteLine(layout);

    foreach (Layer layer in viewInfo.Layers)
        Console.WriteLine(layer);
}

More resources

View CAD Drawings Online

Along with full-featured .NET library we provide simple but powerful free online Apps. View DXF, DWG, and DWF files online with GroupDocs Viewer App.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples: