Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions command.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
"commandName": "create_line_based_element",
"description": "Create line based element such as wall",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "export_room_data",
"description": "Extract all rooms with detailed properties including area, volume, perimeter, and parameters",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "get_material_quantities",
"description": "Calculate material quantities and takeoffs with area and volume calculations per material",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "analyze_model_statistics",
"description": "Analyze model complexity with element counts by category, type, family, and level",
"assemblyPath": "RevitMCPCommandSet.dll"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using RevitMCPCommandSet.Services.DataExtraction;
using RevitMCPSDK.API.Base;

namespace RevitMCPCommandSet.Commands.DataExtraction
{
public class AnalyzeModelStatisticsCommand : ExternalEventCommandBase
{
private AnalyzeModelStatisticsEventHandler _handler => (AnalyzeModelStatisticsEventHandler)Handler;

public override string CommandName => "analyze_model_statistics";

public AnalyzeModelStatisticsCommand(UIApplication uiApp)
: base(new AnalyzeModelStatisticsEventHandler(), uiApp)
{
}

public override object Execute(JObject parameters, string requestId)
{
try
{
// Parse parameters
bool includeDetailedTypes = parameters?["includeDetailedTypes"]?.Value<bool>() ?? true;

// Set parameters
_handler.SetParameters(includeDetailedTypes);

// Execute and wait
if (RaiseAndWaitForCompletion(120000)) // 120 second timeout for large models
{
return _handler.ResultInfo;
}
else
{
throw new TimeoutException("Model statistics analysis timed out");
}
}
catch (Exception ex)
{
throw new Exception($"Failed to analyze model statistics: {ex.Message}");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using RevitMCPCommandSet.Services.DataExtraction;
using RevitMCPSDK.API.Base;

namespace RevitMCPCommandSet.Commands.DataExtraction
{
public class ExportRoomDataCommand : ExternalEventCommandBase
{
private ExportRoomDataEventHandler _handler => (ExportRoomDataEventHandler)Handler;

public override string CommandName => "export_room_data";

public ExportRoomDataCommand(UIApplication uiApp)
: base(new ExportRoomDataEventHandler(), uiApp)
{
}

public override object Execute(JObject parameters, string requestId)
{
try
{
// Parse optional parameters
bool includeUnplacedRooms = parameters?["includeUnplacedRooms"]?.Value<bool>() ?? false;
bool includeNotEnclosedRooms = parameters?["includeNotEnclosedRooms"]?.Value<bool>() ?? false;

// Set parameters
_handler.SetParameters(includeUnplacedRooms, includeNotEnclosedRooms);

// Execute and wait
if (RaiseAndWaitForCompletion(60000)) // 60 second timeout
{
return _handler.ResultInfo;
}
else
{
throw new TimeoutException("Export room data operation timed out");
}
}
catch (Exception ex)
{
throw new Exception($"Failed to export room data: {ex.Message}");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using RevitMCPCommandSet.Services.DataExtraction;
using RevitMCPSDK.API.Base;

namespace RevitMCPCommandSet.Commands.DataExtraction
{
public class GetMaterialQuantitiesCommand : ExternalEventCommandBase
{
private GetMaterialQuantitiesEventHandler _handler => (GetMaterialQuantitiesEventHandler)Handler;

public override string CommandName => "get_material_quantities";

public GetMaterialQuantitiesCommand(UIApplication uiApp)
: base(new GetMaterialQuantitiesEventHandler(), uiApp)
{
}

public override object Execute(JObject parameters, string requestId)
{
try
{
// Parse parameters
List<string> categoryFilters = parameters?["categoryFilters"]?.ToObject<List<string>>();
bool selectedElementsOnly = parameters?["selectedElementsOnly"]?.Value<bool>() ?? false;

// Set parameters
_handler.SetParameters(categoryFilters, selectedElementsOnly);

// Execute and wait
if (RaiseAndWaitForCompletion(120000)) // 120 second timeout for large projects
{
return _handler.ResultInfo;
}
else
{
throw new TimeoutException("Material quantities calculation timed out");
}
}
catch (Exception ex)
{
throw new Exception($"Failed to get material quantities: {ex.Message}");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Newtonsoft.Json;

namespace RevitMCPCommandSet.Models.DataExtraction
{
/// <summary>
/// Model for material quantity data
/// </summary>
public class MaterialQuantityModel
{
[JsonProperty("materialId")]
public long MaterialId { get; set; }

[JsonProperty("materialName")]
public string MaterialName { get; set; }

[JsonProperty("materialClass")]
public string MaterialClass { get; set; }

[JsonProperty("area")]
public double Area { get; set; } // Square feet

[JsonProperty("volume")]
public double Volume { get; set; } // Cubic feet

[JsonProperty("elementCount")]
public int ElementCount { get; set; }

[JsonProperty("elementIds")]
public List<long> ElementIds { get; set; } = new List<long>();
}

/// <summary>
/// Result container for material quantities
/// </summary>
public class GetMaterialQuantitiesResult
{
[JsonProperty("totalMaterials")]
public int TotalMaterials { get; set; }

[JsonProperty("totalArea")]
public double TotalArea { get; set; }

[JsonProperty("totalVolume")]
public double TotalVolume { get; set; }

[JsonProperty("materials")]
public List<MaterialQuantityModel> Materials { get; set; } = new List<MaterialQuantityModel>();

[JsonProperty("success")]
public bool Success { get; set; }

[JsonProperty("message")]
public string Message { get; set; }
}
}
91 changes: 91 additions & 0 deletions revit-mcp-commandset/Models/DataExtraction/ModelStatisticsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using Newtonsoft.Json;

namespace RevitMCPCommandSet.Models.DataExtraction
{
/// <summary>
/// Statistics for a category
/// </summary>
public class CategoryStatistics
{
[JsonProperty("categoryName")]
public string CategoryName { get; set; }

[JsonProperty("elementCount")]
public int ElementCount { get; set; }

[JsonProperty("typeCount")]
public int TypeCount { get; set; }

[JsonProperty("familyCount")]
public int FamilyCount { get; set; }

[JsonProperty("types")]
public List<TypeStatistics> Types { get; set; } = new List<TypeStatistics>();
}

/// <summary>
/// Statistics for a type
/// </summary>
public class TypeStatistics
{
[JsonProperty("typeName")]
public string TypeName { get; set; }

[JsonProperty("familyName")]
public string FamilyName { get; set; }

[JsonProperty("instanceCount")]
public int InstanceCount { get; set; }
}

/// <summary>
/// Statistics by level
/// </summary>
public class LevelStatistics
{
[JsonProperty("levelName")]
public string LevelName { get; set; }

[JsonProperty("elevation")]
public double Elevation { get; set; }

[JsonProperty("elementCount")]
public int ElementCount { get; set; }
}

/// <summary>
/// Result container for model statistics
/// </summary>
public class AnalyzeModelStatisticsResult
{
[JsonProperty("projectName")]
public string ProjectName { get; set; }

[JsonProperty("totalElements")]
public int TotalElements { get; set; }

[JsonProperty("totalTypes")]
public int TotalTypes { get; set; }

[JsonProperty("totalFamilies")]
public int TotalFamilies { get; set; }

[JsonProperty("totalViews")]
public int TotalViews { get; set; }

[JsonProperty("totalSheets")]
public int TotalSheets { get; set; }

[JsonProperty("categories")]
public List<CategoryStatistics> Categories { get; set; } = new List<CategoryStatistics>();

[JsonProperty("levels")]
public List<LevelStatistics> Levels { get; set; } = new List<LevelStatistics>();

[JsonProperty("success")]
public bool Success { get; set; }

[JsonProperty("message")]
public string Message { get; set; }
}
}
70 changes: 70 additions & 0 deletions revit-mcp-commandset/Models/DataExtraction/RoomDataModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Newtonsoft.Json;

namespace RevitMCPCommandSet.Models.DataExtraction
{
/// <summary>
/// Model for room data extraction
/// </summary>
public class RoomDataModel
{
[JsonProperty("id")]
public long Id { get; set; }

[JsonProperty("uniqueId")]
public string UniqueId { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("number")]
public string Number { get; set; }

[JsonProperty("level")]
public string Level { get; set; }

[JsonProperty("area")]
public double Area { get; set; } // Square feet

[JsonProperty("volume")]
public double Volume { get; set; } // Cubic feet

[JsonProperty("perimeter")]
public double Perimeter { get; set; } // Feet

[JsonProperty("unboundedHeight")]
public double UnboundedHeight { get; set; } // Feet

[JsonProperty("department")]
public string Department { get; set; }

[JsonProperty("comments")]
public string Comments { get; set; }

[JsonProperty("phase")]
public string Phase { get; set; }

[JsonProperty("occupancy")]
public string Occupancy { get; set; }
}

/// <summary>
/// Result container for room data export
/// </summary>
public class ExportRoomDataResult
{
[JsonProperty("totalRooms")]
public int TotalRooms { get; set; }

[JsonProperty("totalArea")]
public double TotalArea { get; set; }

[JsonProperty("rooms")]
public List<RoomDataModel> Rooms { get; set; } = new List<RoomDataModel>();

[JsonProperty("success")]
public bool Success { get; set; }

[JsonProperty("message")]
public string Message { get; set; }
}
}
4 changes: 2 additions & 2 deletions revit-mcp-commandset/RevitMCPCommandSet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy /y &quot;$(TargetDir)*.dll&quot; &quot;$(AppData)\Autodesk\Revit\Addins\2024\Commands\RevitMCPCommandSet\2024&quot;&#xD;&#xA;xcopy /y &quot;$(TargetDir)*.pdb&quot; &quot;$(AppData)\Autodesk\Revit\Addins\2024\Commands\RevitMCPCommandSet\2024&quot;" />
</Target>
<Exec Command="xcopy /y /i &quot;$(TargetDir)*.dll&quot; &quot;$(AppData)\Autodesk\Revit\Addins\$(RevitVersion)\revit_mcp_plugin\Commands\RevitMCPCommandSet\$(RevitVersion)&quot;&#xD;&#xA;xcopy /y /i &quot;$(TargetDir)*.pdb&quot; &quot;$(AppData)\Autodesk\Revit\Addins\$(RevitVersion)\revit_mcp_plugin\Commands\RevitMCPCommandSet\$(RevitVersion)&quot;&#xD;&#xA;xcopy /y &quot;$(ProjectDir)..\command.json&quot; &quot;$(AppData)\Autodesk\Revit\Addins\$(RevitVersion)\revit_mcp_plugin\Commands\RevitMCPCommandSet\&quot;" />
</Target>

</Project>
Loading