Skip to content
Merged
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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 revit-mcp-commandset

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions revit-mcp-commandset.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.35906.104 d17.14
VisualStudioVersion = 17.14.35906.104
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "revit-mcp-commandset", "revit-mcp-commandset\revit-mcp-commandset.csproj", "{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitMCPCommandSet", "revit-mcp-commandset\RevitMCPCommandSet.csproj", "{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// RevitAPI-Solutions
// Copyright (c) Duong Tran Quang (DTDucas) ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using RevitMCPSDK.API.Base;
using RevitMCPCommandSet.Models.Annotation;
using RevitMCPCommandSet.Services.AnnotationComponents;

namespace RevitMCPCommandSet.Commands.AnnotationComponents;

/// <summary>
/// Command to create dimensions
/// </summary>
public class CreateDimensionCommand : ExternalEventCommandBase
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="uiApp">Revit UIApplication</param>
public CreateDimensionCommand(UIApplication uiApp)
: base(new CreateDimensionEventHandler(), uiApp)
{
}

private CreateDimensionEventHandler _handler => (CreateDimensionEventHandler)Handler;

/// <summary>
/// Command name
/// </summary>
public override string CommandName => "create_dimensions";

/// <summary>
/// Execute dimension creation command
/// </summary>
/// <param name="parameters">JSON parameters</param>
/// <param name="requestId">Request ID</param>
/// <returns>Execution result</returns>
public override object Execute(JObject parameters, string requestId)
{
try
{
// Parse parameters
var dimensions = parameters["dimensions"]?.ToObject<List<DimensionCreationInfo>>();

if (dimensions == null || dimensions.Count == 0)
throw new ArgumentException("Dimension list cannot be empty");

// Set parameters and execute
_handler.SetParameters(dimensions);

// Raise event and wait for completion
if (RaiseAndWaitForCompletion(20000)) // 20 seconds timeout
return _handler.Result;
throw new TimeoutException("Dimension creation operation timed out");
}
catch (Exception ex)
{
throw new Exception($"Error creating dimensions: {ex.Message}", ex);
}
}
}
13 changes: 4 additions & 9 deletions revit-mcp-commandset/Commands/ColorSplashCommand.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using revit_mcp_sdk.API.Base;
using RevitMCPSDK.API.Base;
using RevitMCPCommandSet.Services;

namespace revit_mcp_commandset.Commands
namespace RevitMCPCommandSet.Commands
{
public class ColorSplashCommand : ExternalEventCommandBase
{
Expand Down
14 changes: 4 additions & 10 deletions revit-mcp-commandset/Commands/CreateLineElementCommand.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
using Autodesk.Revit.UI;
using revit_mcp_commandset.Models;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using revit_mcp_sdk.API.Base;
using RevitMCPCommandSet.Models.Common;
using RevitMCPCommandSet.Services;
using RevitMCPSDK.API.Base;

namespace revit_mcp_commandset.Commands
namespace RevitMCPCommandSet.Commands
{
public class CreateLineElementCommand : ExternalEventCommandBase
{
Expand Down
15 changes: 5 additions & 10 deletions revit-mcp-commandset/Commands/CreatePointElementCommand.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using Autodesk.Revit.UI;
using revit_mcp_commandset.Models;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using revit_mcp_sdk.API.Base;
using RevitMCPSDK.API.Base;
using RevitMCPCommandSet.Models.Common;
using RevitMCPCommandSet.Services;

namespace revit_mcp_commandset.Commands
namespace RevitMCPCommandSet.Commands
{
public class CreatePointElementCommand : ExternalEventCommandBase
public class CreatePointElementCommand : ExternalEventCommandBase
{
private CreatePointElementEventHandler _handler => (CreatePointElementEventHandler)Handler;

Expand Down
13 changes: 4 additions & 9 deletions revit-mcp-commandset/Commands/CreateSurfaceElementCommand.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using Autodesk.Revit.UI;
using revit_mcp_commandset.Models;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using revit_mcp_sdk.API.Base;
using RevitMCPSDK.API.Base;
using RevitMCPCommandSet.Models.Common;
using RevitMCPCommandSet.Services;

namespace revit_mcp_commandset.Commands
namespace RevitMCPCommandSet.Commands
{
public class CreateSurfaceElementCommand : ExternalEventCommandBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using revit_mcp_sdk.API.Base;
using System;
using System.Runtime.InteropServices;
using RevitMCPSDK.API.Base;

namespace revit_mcp_commandset.Commands.Code
namespace RevitMCPCommandSet.Commands.ExecuteDynamicCode
{
/// <summary>
/// 处理代码执行的命令类
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using Autodesk.Revit.DB;
using System.CodeDom.Compiler;
using Autodesk.Revit.UI;
using Microsoft.CSharp;
using Newtonsoft.Json;
using System;
using System.CodeDom.Compiler;
using System.Linq;
using System.Reflection;
using System.Threading;
using revit_mcp_sdk.API.Interfaces;
using RevitMCPSDK.API.Interfaces;

namespace revit_mcp_commandset.Commands.Code
namespace RevitMCPCommandSet.Commands.ExecuteDynamicCode
{
/// <summary>
/// 处理代码执行的外部事件处理器
Expand Down
14 changes: 4 additions & 10 deletions revit-mcp-commandset/Commands/TagWallsCommand.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using revit_mcp_sdk.API.Base;
using revit_mcp_commandset.Commands;
using RevitMCPCommandSet.Services;
using RevitMCPSDK.API.Base;

namespace revit_mcp_commandset.Commands
namespace RevitMCPCommandSet.Commands
{
public class TagWallsCommand : ExternalEventCommandBase
{
Expand Down
25 changes: 0 additions & 25 deletions revit-mcp-commandset/Models/AIResult.cs

This file was deleted.

92 changes: 92 additions & 0 deletions revit-mcp-commandset/Models/Annotation/DimensionCreationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// RevitAPI-Solutions
// Copyright (c) Duong Tran Quang (DTDucas) ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

using Newtonsoft.Json;
using RevitMCPCommandSet.Models.Common;

namespace RevitMCPCommandSet.Models.Annotation;

/// <summary>
/// Information about dimension creation parameters
/// </summary>
public class DimensionCreationInfo
{
/// <summary>
/// Default constructor
/// </summary>
public DimensionCreationInfo()
{
StartPoint = new JZPoint(0, 0, 0);
EndPoint = new JZPoint(0, 0, 0);
ElementIds = new List<int>();
Options = new Dictionary<string, object>();
}

/// <summary>
/// Dimension start point (mm)
/// </summary>
[JsonProperty("startPoint")]
public JZPoint StartPoint { get; set; }

/// <summary>
/// Dimension end point (mm)
/// </summary>
[JsonProperty("endPoint")]
public JZPoint EndPoint { get; set; }

/// <summary>
/// Dimension line point - location of dimension line (mm)
/// </summary>
[JsonProperty("linePoint")]
public JZPoint LinePoint { get; set; }

/// <summary>
/// Elements to dimension
/// </summary>
[JsonProperty("elementIds")]
public List<int> ElementIds { get; set; }

/// <summary>
/// Dimension type
/// </summary>
[JsonProperty("dimensionType")]
public string DimensionType { get; set; } = "Linear";

/// <summary>
/// Dimension style ID
/// </summary>
[JsonProperty("dimensionStyleId")]
public int DimensionStyleId { get; set; } = -1;

/// <summary>
/// View ID - view to create dimension in
/// </summary>
[JsonProperty("viewId")]
public int ViewId { get; set; } = -1;

/// <summary>
/// Additional options
/// </summary>
[JsonProperty("options")]
public Dictionary<string, object> Options { get; set; }
}
Loading