Skip to content

mohamadalitellawi/revit_model_comparison

Repository files navigation

revit_model_comparison

original code generated by Qwen2.5-Max

20250211

Revit Model Comparison with Rhino.Inside.Revit

This repository provides Python scripts to compare two Revit models and visualize changes in Rhino using Grasshopper and Rhino.Inside.Revit. The workflow extracts element data from Revit, compares the differences, and visualizes the results using 3D geometry (Breps) in Rhino.


Folder Structure

Ensure your project directory is organized as follows:

RevitModelComparison/
│
├── main.py # Main script to orchestrate the comparison process
├── data_extraction.py # Functions for extracting element data from Revit models
├── comparison.py # Functions for comparing element data
├── logging_config.py # Logging configuration
└── rhino_visualization.py # Visualization script for Rhino

Installation and Setup

Step 1: Install Required Tools

  1. Install Rhino.Inside.Revit:

    • Download and install Rhino.Inside.Revit.
    • Ensure it matches your Revit version (e.g., Rhino.Inside.Revit 2.x for Revit 2022+).
  2. Install Grasshopper:

    • Open Rhino and ensure Grasshopper is installed and working.
  3. Set Up Python in Grasshopper:

    • Use the Python component in Grasshopper to run Python scripts.
    • Ensure the IronPython engine is enabled.

Workflow

Step 1: Prepare the Python Files

  1. Create a folder named RevitModelComparison.
  2. Save the following Python files into the folder:
    • main.py: Main script for orchestrating the comparison process.
    • data_extraction.py: Extracts element data from Revit models.
    • comparison.py: Compares element data between two models.
    • logging_config.py: Configures logging for error handling.
    • rhino_visualization.py: Visualizes changes in Rhino using layers and 3D geometry.
  3. Verify dependencies and test the scripts locally.

Step 2: Set Up Grasshopper

  1. Open Rhino and Grasshopper:

    • Launch Rhino and open Grasshopper inside Revit using Rhino.Inside.Revit.
  2. Add Python Components:

    • Add two Python components to your Grasshopper canvas:
      • One for running main.py (comparison logic).
      • Another for running rhino_visualization.py (visualization logic).
  3. Set Script Paths:

    • For each Python component, set the script path to the corresponding .py file in the RevitModelComparison folder.
  4. Connect Inputs:

    • For main.py:
      • Pass the active Revit document (doc1) and the second Revit document (doc2) as inputs.
    • For rhino_visualization.py:
      • Pass the outputs of main.py (added_ids, removed_ids, modified_ids) as inputs.
  5. Visualize Geometry:

    • Use Grasshopper components like Brep, Layer, and Custom Preview to display the 3D geometry in Rhino.

Step 3: Run the Workflow

  1. Load Revit Models:

    • Open both Revit models in Revit (doc1 and doc2).
  2. Run Comparison Script:

    • Execute the first Python component (main.py) to compare the models.
    • The script will output lists of added_ids, removed_ids, and modified_ids.
  3. Run Visualization Script:

    • Execute the second Python component (rhino_visualization.py) to retrieve the 3D geometry of the changed elements and assign them to layers.
  4. View Results in Rhino:

    • Switch to Rhino and check the layers:
      • Added: Contains 3D Breps for added elements.
      • Removed: Contains 3D Breps for removed elements.
      • Modified: Contains 3D Breps for modified elements.
    • Toggle layer visibility to focus on specific changes.

Step 4: Debugging and Optimization

  1. Check Logs:

    • Review the logs generated by logging_config.py to identify any errors or warnings.
  2. Handle Missing Geometry:

    • If some elements are missing in Rhino, verify that their geometry is supported by the Revit API and Rhino conversion.
  3. Optimize Performance:

    • For large models, filter specific categories or limit the scope of the comparison to reduce processing time.

Step 5: Extend and Customize

  1. Add More Categories:

    • Modify main.py to include additional categories (e.g., doors, windows, MEP elements).
  2. Customize Layers:

    • Change the layer names or colors in rhino_visualization.py to match your preferences.
  3. Export Results:

    • Extend the scripts to export the comparison results to Excel, JSON, or other formats for reporting.

Key Notes

  • Performance: Extracting and visualizing 3D geometry can be computationally expensive for large models. Optimize by filtering specific categories or limiting the scope of the comparison.
  • Geometry Conversion: Not all Revit elements have direct equivalents in Rhino. Complex parametric families may require additional processing to convert into Breps.
  • Layer Management: Ensure that the layers (Added, Removed, Modified) exist in your Rhino file before running the script. If they don't exist, you can create them programmatically using Rhino's API.

Conclusion

This workflow provides a robust way to compare Revit models and visualize changes in Rhino using Python, Grasshopper, and Rhino.Inside.Revit. By assigning geometry to layers, you can easily manage and analyze differences in your models.

For further assistance, refer to the individual Python files or contact the author.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages