> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Parse diagrams

> Step-by-step guide to extract information from engineering diagrams by detecting and mapping assets and files in Cognite Data Fusion (CDF).

This procedure is for data engineers who need to parse engineering diagrams and map assets and files in Cognite Data Fusion (CDF). You can parse all assets and files from a location or configure detection parameters to narrow the subset.

[Review and verify](#review-parsed-diagrams) the automatic mappings as part of the process.

## Before you start

* Make sure the files you want to parse are ingested into a data model.

* Add [access capabilities](/cdf/access/guides/capabilities#diagram-parsing) for parsing.

* [Configure a location](/cdf/locations/guides/index) for the engineering diagrams.

* Set the `mime_type` to *application/pdf*, *image/jpeg*, *image/png*, or *image/tiff* in [CogniteFile](/cdf/dm/dm_reference/dm_core_data_model#file).

* To test new beta features, select <Icon icon="settings" /> > **Enable beta features** from the overview page.

## Parse a diagram

<Steps>
  <Step title="Navigate to Diagram parsing">
    Navigate to **Data fusion** > **Contextualize** > **Diagram parsing**.
  </Step>

  <Step title="Select location">
    Select the location containing the engineering diagrams.
  </Step>

  <Step title="Choose parsing method">
    Select the file to parse, and then select **Run parsing**.

    <Tabs>
      <Tab title="Tag detection only">
        Detect and link tags to assets and files in CDF. Use for **vector** or **raster** files; supports multi-page files (up to 50 pages per run).
      </Tab>

      <Tab title="Full diagram parsing (public preview)">
        Detect tags and build a data model with equipment relations from diagram content. Use for **vector** files only. To enable **Full diagram parsing**, select <Icon icon="settings" /> on the overview page.

        1. **Select a symbol library**: Choose a [symbol library](/cdf/integration/guides/contextualization/manage_libraries) for detecting symbols in the diagrams.

        <Note>
          Only the first page is processed. If your multi-page PDF contains critical information on subsequent pages, consider splitting the file before parsing.
        </Note>
      </Tab>
    </Tabs>
  </Step>

  <Step title="Configure the parsing">
    **Configure asset filters**: Use the **Assets** tab to filter which assets are included in the parsing.

    **Configure file filters**: Use the **Files** tab to filter which files are parsed.

    **Configure text recognition**: Adjust the text detection settings to improve accuracy.
  </Step>

  <Step title="Run the parsing">
    Select **Run parsing** to process the diagram with your chosen settings.

    <Tip>
      For Full diagram parsing, select **Run advanced parsing** instead of **Run parsing**. The advanced option lets you adjust additional configuration settings before running.
    </Tip>

    <Check>
      The parsing starts and processes your diagram. The time required depends on the file size and complexity.
    </Check>
  </Step>

  <Step title="Review the parsed diagram">
    Select <Icon icon="eye" /> under **Actions** to review the parsed diagram.

    <Check>
      The diagram opens in the review interface with tabs for verifying different aspects of the parsing results.
    </Check>
  </Step>
</Steps>

## Review parsed diagrams

The parsed diagram has four tabs to verify different aspects of the automatic mappings:

| Verification tab                          | What to verify                                                                                                        |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| <Icon icon="type" /> **Tag detection**    | Map asset and file tags to data that's already in CDF.                                                                |
| <Icon icon="shapes" /> **Symbols**        | Verify that the system correctly detected and mapped vectors to symbols. This tab is only available for vector files. |
| <Icon icon="merge" /> **Merge**           | Merge annotations with symbols. This tab is only available for vector files.                                          |
| <Icon icon="git-merge" /> **Connections** | Verify that the system correctly connected the symbols. This tab is only available for vector files.                  |

<Note>
  For vector files, only the first page of the file is parsed. For raster files, you only work with the **Tag detection** tab.
</Note>

<Steps>
  <Step title="Tag detection: Map asset and file tags to CDF">
    1. Verify the detected tags and their links. Select one or several tags to verify or reject links.
           <Note>
             Orange indicates a suggested link. Blue indicates a verified link.
           </Note>
    2. Select the plus icon <Icon icon="plus" /> on the toolbar to create a new tag and link it to an asset or file in CDF.

    <Tip>
      Select **Resize and move annotations** <Icon icon="layers" /> from the toolbar to adjust the position of one or several tags.
    </Tip>

    In the sidebar, page icons with a strikethrough indicate that parsing did not run or returned errors. Rerun the parsing to fix the errors.

    <Check>
      All relevant tags are verified (shown in blue) and correctly linked to assets or files in CDF.
    </Check>
  </Step>

  <Step title="Symbols: Verify vectors as symbols">
    The path selection and symbol creation behavior in this step is part of **Full diagram parsing** (*[public preview](/cdf/product_feature_status#public-preview)*).

    To add symbols to the library, select diagram paths and then select which **Asset class** and **Asset type** the selection represents. You can also add the selection as a geometry to an existing symbol.

    You can select **unassigned** paths (black) and **assigned** paths (orange, already linked to a symbol detection) in the same action when you create a new symbol. You don't need to delete an existing detection first; paths that already belong to another symbol move to the new symbol when you save.

    If a symbol maps to the wrong asset, select the symbol and then **Detach from symbol**. Only this instance in this file is detached from the symbol.

    <Frame>
      <img src="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/integrations/contextualization/symbol_overview_dpp.png" alt="Symbol tab showing detected symbols in the diagram" width="100%" />
    </Frame>

    <Check>
      All vectors are correctly identified and mapped to the appropriate symbols in your library.
    </Check>
  </Step>

  <Step title="Merge: Map tags and symbols">
    Merged tags and symbols appear in blue. For unmerged entities, select the tag and symbol to merge.

    <Check>
      Tags and symbols that represent the same entity are merged and displayed in blue.
    </Check>
  </Step>

  <Step title="Connections: Verify connections">
    Verify that pipes are connected to all connected symbols. If a pipe isn't detected or incorrect, open the **Symbols** tab to make corrections. Hover over a symbol to view the entire connection group and select a symbol to view or edit the closest connection.

    <Check>
      All pipes and connections between symbols are correctly identified and verified.
    </Check>
  </Step>

  <Step title="Rerun parsing to apply changes">
    Rerun the parsing and verify that the system recognized your changes.

    <Tip>
      Select the **Edit layer visibility** icon and turn on *Show background document* to show or hide the diagram's background document details (SVG paths).
    </Tip>

    <Check>
      The parsing completes successfully with all your corrections applied. Review the updated results to confirm accuracy.
    </Check>
  </Step>
</Steps>

## Manage parsed output

Use the API to retrieve your parsed output. For more information, see [API documentation](/api-reference/concepts/20230101/engineering-diagrams).

## Further reading

* [Diagram parsing](/cdf/integration/guides/contextualization/diagram_parsing) – Overview of diagram parsing and data modeling
* [Manage symbol libraries](/cdf/integration/guides/contextualization/manage_libraries) – Create and manage symbol libraries for detection
* [Interactive diagrams](/cdf/integration/guides/contextualization/interactive_diagrams) – Work with diagram data in asset-centric models
* [Troubleshooting diagram parsing](/cdf/integration/guides/contextualization/troubleshooting) – Fix common diagram parsing issues
