Skip to end of metadata
Go to start of metadata
Contents Summary

The feature of getting and rendering the layers is supported since version 18.1.

The feature of getting visibility status of layers is supported since version 19.1.

The code uses some of the objects defined in: Working with Common Operations

Working with Layers in CAD Documents

Using layers in CAD documents is a way of organizing objects in the drawing by associating them with a specific function or a purpose. For example, when we have a complex drawing of the building, all objects can be divided (associated) into several layers - e.g. electrical, water plumbing, furniture, walls and so on. According to your needs, you can temporarily hide or show some of the objects by turning off their layers. GroupDocs.Viewer allows you to get the list of layers from the drawing and supports rendering specified layers.


Getting List of Layers

The following are the steps to get the list of layer names from a CAD document.

  • Create ViewerHandler (ViewerHtmlHandler or ViewerImageHandler)
  • Get document's information in DocumentInfoContainer object using GetDocumentInfo method
  • Cast the DocumentInfoContainer object returned by GetDocumentInfo with CadDocumentInfoContainer
  • Access each layer using CadDocumentInfoContainer.Layers collection

The following code sample shows how to get the list of the layers in a CAD document.

Obtaining Layer's Visibility Status

The layers in a CAD document can be visible or invisible. The layers are invisible when they are frozen or switched off in the original CAD drawing, otherwise, they are visible. Along with the layer's name, Groupdocs.Viewer also allows getting layer's visibility status (visible/invisible). This additional information allows deciding which layer to render relying on a layer's visibility status.

The following code sample shows how to get a layer's visibility status.

Rendering Specific Layers

After you have got the list of layers contained in the drawing, you can specify those that you want to render by adding layer names into the CadOptions.Layers property of corresponding RenderOptions (ImageOptions or HtmlOptions). Please note, when you do not specify layers, all layers are rendered. 

The following code sample shows how to render a specific layer of a CAD document.

This feature is supported in both, the HTML based rendering and the image-based rendering.

Labels
  • No labels