# jhonatan9a/api-.net-autocad architecture

> Architecture diagram of the GitHub repository jhonatan9a/api-.net-autocad, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jhonatan9a/api-.net-autocad
- Repository: https://github.com/jhonatan9a/api-.net-autocad

## Overview

##### Main components
- AutoCAD Environment: Represent the AutoCAD host application where the plugins run.
- Plugin Projects: Each subproject (Base, BlockInsert, ExportPostGIS, RankPolyline) builds its own DLL. Each one acts as an independent module that implements a command to extend AutoCAD’s functionality.
- Development Environment: Show Visual Studio configured for .NET Framework 8. Label configuration elements such as references to AutoCAD libraries (AcDbMgd.dll, AcMgd.dll, AcCoreMgd.dll) which are critical.
- External Dependencies: Mark the AutoCAD .dll files (loaded from C:\Program Files\Autodesk\AutoCAD 20XX\Managed\) and any other external scripts such as SQL scripts and DWG sample files that support testing or demonstration.

##### Relationships and interactions
- That the Visual Studio development environment (and its configuration) compiles the various projects into DLLs.
- Data flows such as:
- From AutoCAD: User command triggers (e.g., entering the command name).
- To Plugin: Execution of the command’s functionalities (block insertion, exporting data to PostGIS, ranking polyline segments, etc.).

##### Important architectural patterns
- Clear separation between compile-time (Visual Studio/.NET Framework) and runtime environment (AutoCAD).
- Environment configuration and reference management (ensuring the proper binaries are not copied locally to prevent conflicts).

##### Relevant technologies and frameworks
- .NET Framework 8 as the target platform.
- Visual Studio as the development IDE.
- AutoCAD’s API via its managed DLLs.
- The pattern of loading external command libraries through the NETLOAD process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Visual Studio Development Environment (.sln, Config)"]:::vsDev

    subgraph "Plugin Projects"
        B["Base Plugin"]:::plugin
        C["BlockInsert Plugin"]:::plugin
        D["ExportPostGIS Plugin"]:::plugin
        E["RankPolyline Plugin"]:::plugin
    end

    F["AutoCAD Host Environment"]:::host
    G["AutoCAD API Libraries (AcDbMgd, AcMgd, AcCoreMgd)"]:::extLib
    H["External Assets (SQL Scripts, DWG Samples)"]:::extAssets

    %% Compilation from Visual Studio to Plugin Projects
    A -->|"compiles_DLLs"| B
    A -->|"compiles_DLLs"| C
    A -->|"compiles_DLLs"| D
    A -->|"compiles_DLLs"| E

    %% Loading plugins into AutoCAD via NETLOAD
    B -->|"NETLOAD"| F
    C -->|"NETLOAD"| F
    D -->|"NETLOAD"| F
    E -->|"NETLOAD"| F

    %% Plugin Dependencies on AutoCAD API Libraries
    B -- "references" --> G
    C -- "references" --> G
    D -- "references" --> G
    E -- "references" --> G

    %% External assets validate commands in AutoCAD Host
    H -->|"validates"| F

    %% Click Events
    click A "https://github.com/jhonatan9a/api-.net-autocad/blob/main/Base/Base.sln"
    click B "https://github.com/jhonatan9a/api-.net-autocad/blob/main/Base/Base/Base.csproj"
    click C "https://github.com/jhonatan9a/api-.net-autocad/blob/main/BlockInsert/BlockInsert.csproj"
    click D "https://github.com/jhonatan9a/api-.net-autocad/blob/main/ExportPostGIS/ExportPostGIS.csproj"
    click E "https://github.com/jhonatan9a/api-.net-autocad/blob/main/RankPolyline/RankPolyline.csproj"

    %% Styles
    classDef vsDev fill:#b3cde0,stroke:#000,stroke-width:2px;
    classDef plugin fill:#ccebc5,stroke:#000,stroke-width:2px;
    classDef host fill:#fbb4ae,stroke:#000,stroke-width:2px;
    classDef extLib fill:#ffffcc,stroke:#000,stroke-width:2px;
    classDef extAssets fill:#fed9a6,stroke:#000,stroke-width:2px;
```
