:orphan:

##########
DGN Reader
##########

.. rst-class:: format-title-block

+------------------------------------------------------------------------------+
|                               **DGN**                                        |
+-----------------------------------------+------------------------------------+
| **File Extension**                      | DGN                                |
+-----------------------------------------+------------------------------------+
| **Supported Versions**                  | 7, 8                               |
+-----------------------------------------+------------------------------------+
| **Platforms**                           | |wy| |ly| |my| |an| |in|           |
+-----------------------------------------+------------------------------------+
| **Tessellation**                        | |t_green| Supported (computed)     |
+-----------------------------------------+------------------------------------+
| :ref:`dgn_brep`                         | |t_green| Generated from file      |
+-----------------------------------------+------------------------------------+
| **PMI**                                 | |c_grey| Not Supported             |
+-----------------------------------------+------------------------------------+
| **Views**                               | |c_grey| Not Supported             |
+-----------------------------------------+------------------------------------+
| **Attributes**                          | |c_grey| Not Supported             |
+-----------------------------------------+------------------------------------+

The DGN (Design) format is a prominent file format used primarily for computer-aided design (CAD) and building information modeling (BIM) applications.
Developed and maintained by Bentley Systems, DGN files are extensively employed in various industries, including architecture, engineering, construction, and geospatial.

How to Import from DGN
======================

To load a DGN file, use :cpp:func:`A3DAsmModelFileLoadFromFile`.
The :cpp:struct:`A3DParamsLoadData` structure is used to customize the loading behavior:

.. code-block:: c

   A3DAsmModelFile* pModelFile = 0;

   A3DRWParamsLoadData sReadParam;
   A3D_INITIALIZE_DATA(A3DRWParamsLoadData, sReadParam);
   sReadParam.m_sGeneral.m_bReadSolids = true;

   // ... set other A3DRWParamsLoadData fields as necessary

   A3DAsmModelFileLoadFromFile("path/to/file.dgn", &sReadParam, &pModelFile);

See :doc:`/guide/basic_operations/load_model` for more about loading model files.

.. _dgn_brep:

B-rep
=====

DGN format does not store the geometry as tessellation or boundary representation.
Instead, we have an exact definition of how to create the geometry
ex: definition of an extrusion, a revolution, a B-spline surface, etc.

HOOPS Exchange interprets these various geometry definitions and translates them into B-rep models.

Levels
======

We provide support of items visibility based on the level they are attached to.

In the DGN format, each item is attached to a level. In the PRC structure, we create a separate layer for each level, assigning a layer id that corresponds to the level number. We set the layer id of each :struct:`A3DRiRepresentationItem` or :struct:`A3DAsmProductOccurrence` to match the level number of its counterpart in the DGN file. To manage layer visibility, a filter is applied on the root :struct:`A3DAsmProductOccurrence` to control the visibility of different layers, based on the GlobalDisplay and GlobalFreeze settings of the respective level in the DGN file.

Limitations
===========

* Topology is not supported for revolutions, except for cones and cylinders.
* Multilines, notes, texts, fonts, and dimensions are not supported.
* Levels

   * Levels are fully supported only for V8 files; they are not for V7 files.
   * Only the GlobalDisplay and GlobalFreeze settings are supported for controlling level visibility. The ViewDisplay setting is not handled.
   * Level numbers greater than 65,535 are not supported. These levels will not be assigned to any :struct:`A3DRiRepresentationItem` or :struct:`A3DAsmProductOccurrence`, and will not be included in the default filter layer list.
   * Changes to color, style, transparency, or material based on level are not yet supported.
* iModel files, with a *.i.dgn* extension, are not supported.
* UV mapping, color, and normal redefinitions are not supported for meshes.
* Reference files that are not in DGN format (such as DWG, IFC, ...) are not supported.