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.
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
-
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+).
-
Install Grasshopper:
- Open Rhino and ensure Grasshopper is installed and working.
-
Set Up Python in Grasshopper:
- Use the
Python
component in Grasshopper to run Python scripts. - Ensure the
IronPython
engine is enabled.
- Use the
- Create a folder named
RevitModelComparison
. - 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.
- Verify dependencies and test the scripts locally.
-
Open Rhino and Grasshopper:
- Launch Rhino and open Grasshopper inside Revit using Rhino.Inside.Revit.
-
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).
- One for running
- Add two
-
Set Script Paths:
- For each
Python
component, set the script path to the corresponding.py
file in theRevitModelComparison
folder.
- For each
-
Connect Inputs:
- For
main.py
:- Pass the active Revit document (
doc1
) and the second Revit document (doc2
) as inputs.
- Pass the active Revit document (
- For
rhino_visualization.py
:- Pass the outputs of
main.py
(added_ids
,removed_ids
,modified_ids
) as inputs.
- Pass the outputs of
- For
-
Visualize Geometry:
- Use Grasshopper components like
Brep
,Layer
, andCustom Preview
to display the 3D geometry in Rhino.
- Use Grasshopper components like
-
Load Revit Models:
- Open both Revit models in Revit (
doc1
anddoc2
).
- Open both Revit models in Revit (
-
Run Comparison Script:
- Execute the first
Python
component (main.py
) to compare the models. - The script will output lists of
added_ids
,removed_ids
, andmodified_ids
.
- Execute the first
-
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.
- Execute the second
-
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.
- Switch to Rhino and check the layers:
-
Check Logs:
- Review the logs generated by
logging_config.py
to identify any errors or warnings.
- Review the logs generated by
-
Handle Missing Geometry:
- If some elements are missing in Rhino, verify that their geometry is supported by the Revit API and Rhino conversion.
-
Optimize Performance:
- For large models, filter specific categories or limit the scope of the comparison to reduce processing time.
-
Add More Categories:
- Modify
main.py
to include additional categories (e.g., doors, windows, MEP elements).
- Modify
-
Customize Layers:
- Change the layer names or colors in
rhino_visualization.py
to match your preferences.
- Change the layer names or colors in
-
Export Results:
- Extend the scripts to export the comparison results to Excel, JSON, or other formats for reporting.
- 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.
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.