How to get CAD layers and layouts

Retrieving 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)
    foreach (Layer layer in viewInfo.Layers)

More resources

GitHub Examples

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

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.