-
Notifications
You must be signed in to change notification settings - Fork 0
Examples DataAnalysis
Truong Giang Vu edited this page Feb 14, 2026
·
2 revisions
Demo: Collect Revit data β Analyze with Polars β Visualize results
Script: data_analysis_script.py
Time: 2-3 minutes
Complete workflow combining all three modules:
- CodeExecute - Auto-install Polars via PEP 723
- Logging - Structured output with syntax highlighting
- Visualization - Display outliers in 3D view
# /// script
# dependencies = [
# "polars==1.38.1",
# ]
# ///When you click Execute:
- CodeExecute checks if
polarsis installed - If missing, UV resolver installs it automatically (~5 seconds)
- Script runs with full access to Polars DataFrame API
from Autodesk.Revit.DB import FilteredElementCollector, Wall
doc = __revit__.ActiveUIDocument.Document
walls = FilteredElementCollector(doc).OfClass(Wall).ToElements()
data = []
for wall in walls:
data.append({
"Id": wall.Id.IntegerValue,
"Name": wall.Name,
"Area": wall.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble(),
})Output in Trace Panel:
Collecting wall data...
Collected 127 walls
import polars as pl
df = pl.DataFrame(data)
# Statistical analysis
stats = df.select(pl.col("Area").describe())
print(stats)
# Find outliers (area > 2 std deviations)
mean_area = df["Area"].mean()
std_area = df["Area"].std()
outliers = df.filter(pl.col("Area") > mean_area + 2 * std_area)Output in Trace Panel:
Wall Area Statistics:
ββββββββββββ¬βββββββββββββ
β statisticβ value β
ββββββββββββΌβββββββββββββ€
β count β 127.0 β
β mean β 245.8 β
β std β 78.3 β
β min β 12.5 β
β max β 892.1 β
ββββββββββββ΄βββββββββββββ
Found 3 outlier walls
# Get walls from outlier IDs
outlier_ids = [ElementId(id) for id in outliers["Id"]]
outlier_walls = [doc.GetElement(id) for id in outlier_ids]
# Print geometry β auto-visualized in 3D
for wall in outlier_walls:
curve = wall.Location.Curve
print(f"Wall {wall.Id}: Area={wall_area:.1f} sq ft")
print(curve) # Appears in 3D view with colorResult:
- Outlier walls highlighted in 3D view
- Trace Panel shows IDs + areas
- Clear visual feedback for analysis
- Open RevitDevTool panel
- Navigate to CodeExecute tab
-
Load folder:
source/RevitDevTool.PythonDemo/commands/ -
Click
data_analysis_script.py - Watch dependencies install (first run only)
- See results in Trace Panel + 3D view
Full source: data_analysis_script.py
-
Logging tests β
logging_format_script.py -
Visualization tests β
visualization_curve_script.py -
Dashboard UI β
dashboard_script.py