# gcra101/revit-steel-reuse-tool architecture

> Architecture diagram of the GitHub repository gcra101/revit-steel-reuse-tool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gcra101/revit-steel-reuse-tool
- Repository: https://github.com/gcra101/revit-steel-reuse-tool

## Overview

##### Project Type and Purpose
- This is a desktop plugin suite for Autodesk Revit, implemented in C#/.NET (ReuseSchemeTool.sln).
- It consists of two complementary Revit add-ins (“Inspector Tool” and “Scheme Tool”) to assess existing steel frames for reuse and generate multi-format outputs (Revit sheets, Excel, PDF, JSON).
- The solution follows an MVC-style layering inside a host-plugin architecture and relies on the Revit API, Office Interop (Excel/PDF), and Newtonsoft.Json.

##### High-Level Architectural Components
a. Host Application
- Autodesk Revit (2020+)
- Loads .addin definition files and DLLs
b. Plugin Loader & Ribbon UI
- RevitRibbonTabsFactory (reads .addin XML, constructs “BH Plugins” tab)
- RibbonItemFactory / RibbonTabPanelFactory
c. Commands / Entry Points
- CommandInspectorTool.cs
- CommandSchemeTool.cs
- Implements IExternalCommand, invoked from Ribbon buttons
d. Controller Layer
- RST_Controller, EventsListener, AudioManagerInterface, ExceptionHandler, FilePathRetriever, MissingInputsHandler
- Manages workflow: splash screens, input collection, progress bar, error handling, sound cues
e. View Layer
- WinForms / WPF dialogs under view/ (InputsView, AboutBox, SplashScreen, ProgressBar)
- view/revit_plugin for Ribbon UI factories and command wiring
f. Model Layer
- Core domain: RST_Model, SteelFrame, FrameDecorator, Geometry, SurveyInfo, ReuseRatingCalculator, ReuseRatingStrategy, ProposedSteelFrame
- Data structures: RBTree, Observer pattern
- Converters & serializers: JSONSerializer, ExcelChartFactory, ExcelDataManager, RevitConverterInterface
- File managers: ControllerFileManager, RevitFileManager
- Configuration: AppConfig, InputSettings, EMRInputSettings
g. External Services & Outputs
- Revit API (collecting elements, creating sheets/views)
- Microsoft Office Interop (Excel, PDF)
- JSON (Newtonsoft.Json)
- Embedded resource files (images, sounds, text templates)

##### Relationships and Data Flows
- Revit UI ➔ Ribbon command activation ➔ CommandInspectorTool / CommandSchemeTool
- Command ➔ Controller orchestrates:
- View: show splash → about → inputs → folder picker → progress
- Model: collect Revit elements → calculate reuse ratings → decorate frames
- Output services: write Excel/PDF/JSON → push Revit ViewSheet
- Controller uses File Managers to read/write settings, Excel templates, text files.
- Model uses Observer pattern to notify views of progress.

##### Architectural Patterns and Principles
- Host-Plugin architecture (Revit as shell, add-ins as plugins)
- Model-View-Controller (separation of UI, orchestration, domain logic)
- Strategy pattern (ReuseRatingStrategy, RevitElemCollectorStrategy)
- Factory pattern (RibbonItemFactory, ExcelChartFactory, ColorsFactory)
- Observer pattern for progress updates
- Adapter pattern (ColorAdapter, RevitConverterInterface)

##### Technologies, Frameworks, Libraries
- .NET Framework (C#)
- Autodesk Revit API
- Windows Forms / WPF (dialog-based UI)
- Newtonsoft.Json
- Office Interop (Excel, PDF)
- Embedded resource management (sounds, images)

##### Essential Details
- Class groupings: controller/, model/, view/, view/revit_plugin/.
- Data managers (ExcelDataManager, JSONSerializer) as subcomponents of Output Services.
- Shared utilities (FileManager, Config).
- Don’t over-complicate—split into as many logical components as possible for clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Revit Host
    Host["Autodesk Revit Host"]:::revit

    %% Plugin Loader & Ribbon UI
    subgraph "Plugin Loader & Ribbon UI"
        direction TB
        Addin["ReuseSchemeTool.addin"]:::loader
        RibbonItemFactory["RibbonItemFactory"]:::loader
        RibbonTabPanelFactory["RibbonTabPanelFactory"]:::loader
        RibbonUI["RibbonUI"]:::loader
        BitmapImageFactory["BitmapImageFactory"]:::loader
    end

    %% Commands / Entry Points
    subgraph "Commands Layer"
        direction TB
        CommandBase["Command (IExternalCommand)"]:::commands
        InspectorCmd["CommandInspectorTool"]:::commands
        SchemeCmd["CommandSchemeTool"]:::commands
    end

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        Controller["RST_Controller"]:::controller
        EventsListener["EventsListener"]:::controller
        AudioInterface["AudioManagerInterface"]:::controller
        SoundManager["SoundManager"]:::controller
        Sound["Sound"]:::controller
        SoundRetriever["SoundPathRetriever"]:::controller
        FilePathRetriever["FilePathRetriever"]:::controller
        MissingInputs["MissingInputsHandler"]:::controller
        ExceptionHandler["ExceptionHandler"]:::controller
        ExceptionInterface["ExceptionHandlerInterface"]:::controller
        ControllerFileMgr["ControllerFileManager"]:::controller
        Document["Document"]:::controller
    end

    %% View Layer
    subgraph "View Layer"
        direction TB
        InputsView["InputsView"]:::view
        SplashInspector["InspectorTool_SplashScreen"]:::view
        AboutInspector["InspectorTool_AboutBox"]:::view
        ProgressInspector["InspectorTool_ProgrBarView"]:::view
        SplashScheme["SchemingTool_SplashScreen"]:::view
        AboutScheme["SchemingTool_AboutBox"]:::view
        ProgressScheme["SchemingTool_ProgrBarView"]:::view
        RSTView["RST_View"]:::view
        DockType["DockType"]:::view
        ProcessNameRetriever["ProcessNameRetriever"]:::view
        WindowResizer["WindowResizer"]:::view
    end

    %% Model Layer
    subgraph "Model Layer"
        direction TB
        subgraph "Core Domain & DTOs"
            RSTModel["RST_Model"]:::model
            SteelFrame["SteelFrame"]:::model
            ExistingFrame["ExistingSteelFrame"]:::model
            ProposedFrame["ProposedSteelFrame"]:::model
            Frame["Frame / FrameDecorator"]:::model
            Geometry["Geometry / Geometry1D"]:::model
            SurveyInfo["SurveyInfo"]:::model
            ReuseCalc["ReuseRatingCalculator"]:::model
            ReuseStrategy["ReuseRatingStrategy"]:::model
        end
        subgraph "Data Structures"
            RBTree["RBTree"]:::model
            Observable["Observable / Observer"]:::model
        end
        subgraph "Converters & Serializers"
            JSONSer["JSONSerializer"]:::model
            ExcelChart["ExcelChartFactory"]:::model
            ExcelData["ExcelDataManager"]:::model
            RevitConverter["RevitConverterInterface"]:::model
        end
        subgraph "File Managers & Config"
            FileMgr["FileManager"]:::model
            RevitFileMgr["RevitFileManager"]:::model
            AppConfig["AppConfig"]:::model
            InputSettings["InputSettings / EMRInputSettings"]:::model
        end
        subgraph "Revit Integration"
            RevCollector["CollectorStrategy"]:::model
            ViewSheetBuilder["ViewSheetBuilder"]:::model
            ColorsFactory["ColorsFactory"]:::model
        end
    end

    %% External Services & Outputs
    subgraph "External Services & Outputs"
        direction TB
        RevitAPI["Revit API"]:::external
        OfficeInterop["Office Interop (Excel/PDF)"]:::external
        JSONExt["Newtonsoft.Json"]:::external
        Resources["Embedded Resources"]:::external
    end

    %% Connections
    Host -->|loads| Addin
    Host -->|loads| RibbonUI
    Addin --> RibbonItemFactory
    Addin --> RibbonTabPanelFactory
    RibbonItemFactory --> RibbonUI
    RibbonTabPanelFactory --> RibbonUI
    RibbonUI --> CommandBase
    CommandBase --> InspectorCmd
    CommandBase --> SchemeCmd
    InspectorCmd --> Controller
    SchemeCmd --> Controller
    Controller --> InputsView
    Controller --> SplashInspector
    Controller --> AboutInspector
    Controller --> ProgressInspector
    Controller --> SplashScheme
    Controller --> AboutScheme
    Controller --> ProgressScheme
    Controller --> RSTModel
    Controller --> FileMgr
    RSTModel --> SteelFrame
    RSTModel --> ExistingFrame
    RSTModel --> ProposedFrame
    RSTModel --> ReuseCalc
    ReuseCalc --> ReuseStrategy
    ExcelData --> OfficeInterop
    JSONSer --> JSONExt
    RevitConverter --> RevitAPI
    ControllerFileMgr --> FileMgr
    Controller --> ControllerFileMgr
    Controller --> FilePathRetriever
    Controller --> MissingInputs
    Controller --> ExceptionHandler
    Controller --> AudioInterface
    AudioInterface --> SoundManager
    SoundManager --> Sound
    SoundManager --> SoundRetriever
    Resources -.-> SoundRetriever

    %% Click Events: Plugin Loader & Ribbon UI
    click Addin "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/ReuseSchemeTool.addin"
    click RibbonItemFactory "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/view/revit_plugin/RibbonItemFactory.cs"
    click RibbonTabPanelFactory "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/view/revit_plugin/RibbonTabPanelFactory.cs"
    click RibbonUI "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/view/revit_plugin/RibbonUI.cs"
    click BitmapImageFactory "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/view/revit_plugin/BitmapImageFactory.cs"

    %% Click Events: Commands
    click InspectorCmd "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/view/revit_plugin/CommandInspectorTool.cs"
    click SchemeCmd "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/view/revit_plugin/CommandSchemeTool.cs"
    click CommandBase "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/view/revit_plugin/Command.cs"

    %% Click Events: Controller Layer
    click Controller "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/RST_Controller.cs"
    click EventsListener "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/EventsListener.cs"
    click AudioInterface "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/AudioManagerInterface.cs"
    click SoundManager "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/SoundManager.cs"
    click Sound "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/Sound.cs"
    click SoundRetriever "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/SoundPathRetriever.cs"
    click FilePathRetriever "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/FilePathRetriever.cs"
    click MissingInputs "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/MissingInputsHandler.cs"
    click ExceptionHandler "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/ExceptionHandler.cs"
    click ExceptionInterface "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/ExceptionHandlerInterface.cs"
    click ControllerFileMgr "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/ControllerFileManager.cs"
    click Document "https://github.com/gcra101/revit-steel-reuse-tool/blob/main/ReuseSchemeTool/controller/Document.cs"

    %% Class Definitions
    classDef revit fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef loader fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef commands fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20
    classDef controller fill:#DCEDC8,stroke:#33691E,color:#33691E
    classDef view fill:#FFF9C4,stroke:#F57F17,color:#F57F17
    classDef model fill:#FFE0B2,stroke:#E65100,color:#E65100
    classDef external fill:#E1BEE7,stroke:#4A148C,color:#4A148C
```
