Free Support Forum - groupdocs.com

CAD sample does not show layouts in .NET

Executing the function “GetViewInfoForCadDrawing” from the Viewer sample returns the following output:

Document type is: AutoCAD Drawing Database File (.dwg)
Pages count: 1
Model 26x23px
QUADRANT (visible)
TRIANGLE (visible)
CIRCLE (visible)
0 (visible)

CAD info obtained successfully.

As the filename says, the drawing has layers and layouts, but only the layers are returned by GroupDocs.Viewer.
Tested with the 21.2 for .NET with your sample from GroupDocs.Viewer.Examples.CSharp.AdvancedUsage.Rendering.RenderingOptionsByDocumentType.RenderingCadDrawings:

@Clemens_Pestuka

By default, we’re rendering the only Model and it is listed on the third row of the output you’ve provided. To render all layouts please set CadOptions.RenderLayouts = true as is shown in the code snippet

using (Viewer viewer = new Viewer("with_layers_and_layouts.dwg"))
{
    ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
    viewInfoOptions.CadOptions.RenderLayouts = true;

    CadViewInfo info = viewer.GetViewInfo(viewInfoOptions) as CadViewInfo;

    Console.WriteLine("Document type is: " + info.FileType);
    Console.WriteLine("Pages count: " + info.Pages.Count);

    Console.WriteLine("\nLayouts:");
    foreach (Layout layout in info.Layouts)
        Console.WriteLine(layout);

    Console.WriteLine("\nLayers:");
    foreach (Layer layer in info.Layers)
        Console.WriteLine(layer);
}

The output would be the similar to this

Document type is: AutoCAD Drawing Database File (.dwg)
Pages count: 4

Layouts:
Model 26x23px
Layout1 2520x1920px
Layout2 2520x1920px
Layout3 2520x1920px

Layers:
QUADRANT (visible)
TRIANGLE (visible)
CIRCLE (visible)
0 (visible)

The corresponding code example has been updated to clarify the default behavior.

1 Like

@vladimir.litvinchik

Yes that fixes it!
Thank you for the quick answer and detailed description. :+1:

1 Like

@Clemens_Pestuka

You’re welcome!

1 Like