Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
Closed
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
96 changes: 62 additions & 34 deletions command.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,99 @@
},
"commands": [
{
"commandName": "say_hello",
"description": "Displays a greeting dialog",
"commandName": "ai_element_filter",
"description": "ai element filter",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "get_available_family_types",
"description": "get available family types",
"commandName": "analyze_model_statistics",
"description": "Analyze model complexity with element counts by category, type, family, and level",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "get_current_view_elements",
"description": "get current view elements",
"commandName": "color_splash",
"description": "color splash",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "get_current_view_info",
"description": "get current view info",
"commandName": "create_dimensions",
"description": "create dimensions",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "create_Wall",
"description": "create a wall",
"commandName": "create_grid",
"description": "Create grid system with smart spacing generation for project layout (alphabetic/numeric naming)",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "delete_element",
"description": "Deletes elements using ElementId",
"commandName": "create_line_based_element",
"description": "Create line based element such as wall",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "tag_all_walls",
"description": "Tag all the walls in the model",
{
"commandName": "create_point_based_element",
"description": "create point based element",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "create_line_based_element",
"description": "Create line based element such as wall",
{
"commandName": "create_structural_framing_system",
"description": "Create structural beam framing system with configurable spacing and direction",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "create_surface_based_element",
"description": "create surface based element",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
{
"commandName": "delete_element",
"description": "Deletes elements using ElementId",
"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_available_family_types",
"description": "get available family types",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "get_current_view_elements",
"description": "get current view elements",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "get_current_view_info",
"description": "get current view info",
"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",
{
"commandName": "get_selected_elements",
"description": "get selected elements",
"assemblyPath": "RevitMCPCommandSet.dll"
}
,
{
"commandName": "create_grid",
"description": "Create grid system with smart spacing generation for project layout (alphabetic/numeric naming)",
},
{
"commandName": "operate_element",
"description": "operate element",
"assemblyPath": "RevitMCPCommandSet.dll"
}
,
{
"commandName": "create_structural_framing_system",
"description": "Create structural beam framing system with configurable spacing and direction",
},
{
"commandName": "send_code_to_revit",
"description": "send code to revit",
"assemblyPath": "RevitMCPCommandSet.dll"
},
{
"commandName": "tag_all_walls",
"description": "Tag all the walls in the model",
"assemblyPath": "RevitMCPCommandSet.dll"
}
]
}
}
6 changes: 6 additions & 0 deletions revit-mcp-commandset.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ Global
Debug R23|Any CPU = Debug R23|Any CPU
Debug R24|Any CPU = Debug R24|Any CPU
Debug R25|Any CPU = Debug R25|Any CPU
Debug R26|Any CPU = Debug R26|Any CPU
Release R20|Any CPU = Release R20|Any CPU
Release R21|Any CPU = Release R21|Any CPU
Release R22|Any CPU = Release R22|Any CPU
Release R23|Any CPU = Release R23|Any CPU
Release R24|Any CPU = Release R24|Any CPU
Release R25|Any CPU = Release R25|Any CPU
Release R26|Any CPU = Release R26|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R20|Any CPU.ActiveCfg = Debug R20|Any CPU
Expand All @@ -33,6 +35,8 @@ Global
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R24|Any CPU.Build.0 = Debug R24|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R25|Any CPU.ActiveCfg = Debug R25|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R25|Any CPU.Build.0 = Debug R25|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R26|Any CPU.ActiveCfg = Debug R26|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R26|Any CPU.Build.0 = Debug R26|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R20|Any CPU.ActiveCfg = Release R20|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R20|Any CPU.Build.0 = Release R20|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R21|Any CPU.ActiveCfg = Release R21|Any CPU
Expand All @@ -45,6 +49,8 @@ Global
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R24|Any CPU.Build.0 = Release R24|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R25|Any CPU.ActiveCfg = Release R25|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R25|Any CPU.Build.0 = Release R25|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R26|Any CPU.ActiveCfg = Release R26|Any CPU
{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R26|Any CPU.Build.0 = Release R26|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 7 additions & 3 deletions revit-mcp-commandset/RevitMCPCommandSet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<PlatformTarget>x64</PlatformTarget>
<ImplicitUsings>true</ImplicitUsings>
<PublishAddinFiles>true</PublishAddinFiles>
<Configurations>Debug R20;Debug R21;Debug R22;Debug R23;Debug R24;Debug R25</Configurations>
<Configurations>$(Configurations);Release R20;Release R21;Release R22;Release R23;Release R24;Release R25</Configurations>
<Configurations>Debug R20;Debug R21;Debug R22;Debug R23;Debug R24;Debug R25;Debug R26</Configurations>
<Configurations>$(Configurations);Release R20;Release R21;Release R22;Release R23;Release R24;Release R25;Release R26</Configurations>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.Contains('R20'))">
Expand All @@ -34,6 +34,10 @@
<RevitVersion>2025</RevitVersion>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('R26'))">
<RevitVersion>2026</RevitVersion>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<StartAction>Program</StartAction>
Expand All @@ -59,4 +63,4 @@
<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>
</Project>
49 changes: 25 additions & 24 deletions revit-mcp-commandset/Services/AIElementFilterEventHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI;
Expand Down Expand Up @@ -386,7 +386,7 @@ public static ElementInstanceInfo CreateElementFullInfo(Document doc, Element el

ElementInstanceInfo elementInfo = new ElementInstanceInfo(); //创建存储元素完整信息的自定义类
// ID
elementInfo.Id = element.Id.IntegerValue;
elementInfo.Id = ElementIdUtils.GetIdValue(element.Id);
// UniqueId
elementInfo.UniqueId = element.UniqueId;
// 类型名称
Expand All @@ -396,12 +396,12 @@ public static ElementInstanceInfo CreateElementFullInfo(Document doc, Element el
// 类别
elementInfo.Category = element.Category.Name;
// 内置类别
elementInfo.BuiltInCategory = Enum.GetName(typeof(BuiltInCategory), element.Category.Id.IntegerValue);
elementInfo.BuiltInCategory = Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(element.Category.Id));
// 类型Id
elementInfo.TypeId = element.GetTypeId().IntegerValue;
elementInfo.TypeId = ElementIdUtils.GetIdValue(element.GetTypeId());
//所属房间Id
if (element is FamilyInstance instance)
elementInfo.RoomId = instance.Room?.Id.IntegerValue ?? -1;
elementInfo.RoomId = ElementIdUtils.GetIdValue(instance.Room?.Id);
// 标高
elementInfo.Level = GetElementLevel(doc, element);
// 最大包围盒
Expand Down Expand Up @@ -438,7 +438,7 @@ public static ElementTypeInfo CreateTypeFullInfo(Document doc, ElementType eleme
{
ElementTypeInfo typeInfo = new ElementTypeInfo();
// Id
typeInfo.Id = elementType.Id.IntegerValue;
typeInfo.Id = ElementIdUtils.GetIdValue(elementType.Id);
// UniqueId
typeInfo.UniqueId = elementType.UniqueId;
// 类型名称
Expand All @@ -448,7 +448,7 @@ public static ElementTypeInfo CreateTypeFullInfo(Document doc, ElementType eleme
// 类别
typeInfo.Category = elementType.Category.Name;
// 内置类别
typeInfo.BuiltInCategory = Enum.GetName(typeof(BuiltInCategory), elementType.Category.Id.IntegerValue);
typeInfo.BuiltInCategory = Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(elementType.Category.Id));
// 参数字典
typeInfo.Parameters = GetDimensionParameters(elementType);
ParameterInfo thicknessParam = GetThicknessInfo(elementType); //厚度参数
Expand All @@ -470,13 +470,13 @@ public static PositioningElementInfo CreatePositioningElementInfo(Document doc,
return null;
PositioningElementInfo info = new PositioningElementInfo
{
Id = element.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(element.Id),
UniqueId = element.UniqueId,
Name = element.Name,
FamilyName = element?.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString(),
Category = element.Category?.Name,
BuiltInCategory = element.Category != null ?
Enum.GetName(typeof(BuiltInCategory), element.Category.Id.IntegerValue) : null,
Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(element.Category.Id)) : null,
ElementClass = element.GetType().Name,
BoundingBox = GetBoundingBoxInfo(element)
};
Expand Down Expand Up @@ -525,13 +525,13 @@ public static SpatialElementInfo CreateSpatialElementInfo(Document doc, Element
SpatialElement spatialElement = element as SpatialElement;
SpatialElementInfo info = new SpatialElementInfo
{
Id = element.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(element.Id),
UniqueId = element.UniqueId,
Name = element.Name,
FamilyName = element?.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString(),
Category = element.Category?.Name,
BuiltInCategory = element.Category != null ?
Enum.GetName(typeof(BuiltInCategory), element.Category.Id.IntegerValue) : null,
Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(element.Category.Id)) : null,
ElementClass = element.GetType().Name,
BoundingBox = GetBoundingBoxInfo(element)
};
Expand Down Expand Up @@ -588,13 +588,13 @@ public static ViewInfo CreateViewInfo(Document doc, Element element)

ViewInfo info = new ViewInfo
{
Id = element.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(element.Id),
UniqueId = element.UniqueId,
Name = element.Name,
FamilyName = element?.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString(),
Category = element.Category?.Name,
BuiltInCategory = element.Category != null ?
Enum.GetName(typeof(BuiltInCategory), element.Category.Id.IntegerValue) : null,
Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(element.Category.Id)) : null,
ElementClass = element.GetType().Name,
ViewType = view.ViewType.ToString(),
Scale = view.Scale,
Expand All @@ -609,7 +609,7 @@ public static ViewInfo CreateViewInfo(Document doc, Element element)
Level level = viewPlan.GenLevel;
info.AssociatedLevel = new LevelInfo
{
Id = level.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(level.Id),
Name = level.Name,
Height = level.Elevation * 304.8 // 转换为mm
};
Expand All @@ -624,12 +624,12 @@ public static ViewInfo CreateViewInfo(Document doc, Element element)
foreach (UIView uiView in openViews)
{
// 检查视图是否打开
if (uiView.ViewId.IntegerValue == view.Id.IntegerValue)
if (ElementIdUtils.GetIdValue(uiView.ViewId) == ElementIdUtils.GetIdValue(view.Id))
{
info.IsOpen = true;

// 检查视图是否是当前激活的视图
if (uidoc.ActiveView.Id.IntegerValue == view.Id.IntegerValue)
if (ElementIdUtils.GetIdValue(uidoc.ActiveView.Id) == ElementIdUtils.GetIdValue(view.Id))
{
info.IsActive = true;
}
Expand All @@ -656,13 +656,13 @@ public static AnnotationInfo CreateAnnotationInfo(Document doc, Element element)
return null;
AnnotationInfo info = new AnnotationInfo
{
Id = element.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(element.Id),
UniqueId = element.UniqueId,
Name = element.Name,
FamilyName = element?.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString(),
Category = element.Category?.Name,
BuiltInCategory = element.Category != null ?
Enum.GetName(typeof(BuiltInCategory), element.Category.Id.IntegerValue) : null,
Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(element.Category.Id)) : null,
ElementClass = element.GetType().Name,
BoundingBox = GetBoundingBoxInfo(element)
};
Expand Down Expand Up @@ -733,13 +733,13 @@ public static GroupOrLinkInfo CreateGroupOrLinkInfo(Document doc, Element elemen
return null;
GroupOrLinkInfo info = new GroupOrLinkInfo
{
Id = element.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(element.Id),
UniqueId = element.UniqueId,
Name = element.Name,
FamilyName = element?.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString(),
Category = element.Category?.Name,
BuiltInCategory = element.Category != null ?
Enum.GetName(typeof(BuiltInCategory), element.Category.Id.IntegerValue) : null,
Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(element.Category.Id)) : null,
ElementClass = element.GetType().Name,
BoundingBox = GetBoundingBoxInfo(element)
};
Expand Down Expand Up @@ -804,13 +804,13 @@ public static ElementBasicInfo CreateElementBasicInfo(Document doc, Element elem
return null;
ElementBasicInfo basicInfo = new ElementBasicInfo
{
Id = element.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(element.Id),
UniqueId = element.UniqueId,
Name = element.Name,
FamilyName = element?.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString(),
Category = element.Category?.Name,
BuiltInCategory = element.Category != null ?
Enum.GetName(typeof(BuiltInCategory), element.Category.Id.IntegerValue) : null,
Enum.GetName(typeof(BuiltInCategory), ElementIdUtils.GetIdValue(element.Category.Id)) : null,
BoundingBox = GetBoundingBoxInfo(element)
};
return basicInfo;
Expand Down Expand Up @@ -854,7 +854,7 @@ public static ParameterInfo GetThicknessInfo(Element element)
}
else if (elementType is FamilySymbol familySymbol)
{
switch (familySymbol.Category?.Id.IntegerValue)
switch (ElementIdUtils.GetIdValue(familySymbol.Category?.Id))
{
case (int)BuiltInCategory.OST_Doors:
case (int)BuiltInCategory.OST_Windows:
Expand Down Expand Up @@ -932,7 +932,7 @@ public static LevelInfo GetElementLevel(Document doc, Element element)
{
LevelInfo levelInfo = new LevelInfo
{
Id = level.Id.IntegerValue,
Id = ElementIdUtils.GetIdValue(level.Id),
Name = level.Name,
Height = level.Elevation * 304.8
};
Expand Down Expand Up @@ -1546,3 +1546,4 @@ public class LevelInfo


}

Loading