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.

    Viewer viewer = new Viewer("sample.dwg");
    ViewInfoOptions viewInfoOptions = ViewInfoOptions.forHtmlView();
    CadViewInfo viewInfo = (CadViewInfo) viewer.getViewInfo(viewInfoOptions);

    System.out.println("File type: " + viewInfo.getFileType());
    System.out.println("Pages count: " + viewInfo.getPages().size());

    for (Layout layout : viewInfo.getLayouts()) {
        System.out.println(layout);
    }

    for (Layer layer : viewInfo.getLayers()) {
        System.out.println(layer);
    }

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 Java 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.