├── .github ├── CODE_OF_CONDUCT.md └── CONTRIBUTING.md ├── .gitignore ├── LICENSE ├── README.md ├── revit-mcp-commandset.sln └── revit-mcp-commandset ├── Commands ├── AIElementFilterCommand.cs ├── Access │ ├── GetAvailableFamilyTypesCommand.cs │ ├── GetCurrentViewElementsCommand.cs │ ├── GetCurrentViewInfoCommand.cs │ └── GetSelectedElementsCommand.cs ├── AnnotationComponents │ └── CreateDimensionCommand.cs ├── ColorSplashCommand.cs ├── CreateLineElementCommand.cs ├── CreatePointElementCommand.cs ├── CreateSurfaceElementCommand.cs ├── Delete │ └── DeleteElementCommand.cs ├── ExecuteDynamicCode │ ├── ExecuteCodeCommand.cs │ └── ExecuteCodeEventHandler.cs ├── OperateElementCommand.cs └── TagWallsCommand.cs ├── Models ├── Annotation │ ├── DimensionCreationInfo.cs │ ├── TagCreationInfo.cs │ └── TextNoteCreationInfo.cs ├── Architecture │ ├── AreaCreationInfo.cs │ ├── BalconyInfo.cs │ ├── BeamInfo.cs │ ├── BuildingInfo.cs │ ├── CeilingCreationInfo.cs │ ├── ColumnInfo.cs │ ├── DoorInfo.cs │ ├── FloorInfo.cs │ ├── FoundationInfo.cs │ ├── GridInfo.cs │ ├── GroupCreationInfo.cs │ ├── LevelInfo.cs │ ├── ModelCurveCreationInfo.cs │ ├── OpeningCreationInfo.cs │ ├── RailingCreationInfo.cs │ ├── RampCreationInfo.cs │ ├── ReferencePlaneCreationInfo.cs │ ├── RoofInfo.cs │ ├── RoomCreationInfo.cs │ ├── ShaftCreationInfo.cs │ ├── StairCreationInfo.cs │ ├── WallCreationInfo.cs │ ├── WindowInfo.cs │ └── ZoneCreationInfo.cs ├── Common │ ├── AIResult.cs │ ├── ElementInfo.cs │ ├── FamilyTypeInfo.cs │ ├── FilterSetting.cs │ ├── JZFace.cs │ ├── JZLine.cs │ ├── JZPoint.cs │ ├── LineElement.cs │ ├── OperationSetting.cs │ ├── PointElement.cs │ ├── SurfaceElement.cs │ ├── ViewElementsResult.cs │ └── ViewInfo.cs ├── MEP │ ├── ConduitCreationInfo.cs │ ├── DuctCreationInfo.cs │ ├── EquipmentCreationInfo.cs │ └── PipeCreationInfo.cs └── Views │ ├── ScheduleCreationInfo.cs │ ├── SheetCreationInfo.cs │ ├── SheetInfo.cs │ ├── ViewCreationInfo.cs │ └── ViewportCreationInfo.cs ├── RevitMCPCommandSet.csproj ├── Services ├── AIElementFilterEventHandler.cs ├── AnnotationComponents │ └── CreateDimensionEventHandler.cs ├── ColorSplashEventHandler.cs ├── CreateLineElementEventHandler.cs ├── CreatePointElementEventHandler.cs ├── CreateSurfaceElementEventHandler.cs ├── DeleteElementEventHandler.cs ├── GetAvailableFamilyTypesEventHandler.cs ├── GetCurrentViewElementsEventHandler.cs ├── GetCurrentViewInfoEventHandler.cs ├── GetSelectedElementsEventHandler.cs ├── OperateElementEventHandler.cs └── TagWallsEventHandler.cs └── Utils ├── DeleteWarningSuperUtils.cs ├── GeometryUtils.cs ├── HandleDuplicateTypeUtils.cs ├── JsonSchemaGenerator.cs ├── ProjectUtils.cs └── TransactionUtils.cs /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. 6 | 7 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 8 | 9 | ## Our Standards 10 | 11 | Examples of behavior that contributes to a positive environment for our community include: 12 | 13 | - Demonstrating empathy and kindness toward others 14 | - Respecting differing opinions, viewpoints, and experiences 15 | - Giving and gracefully accepting constructive feedback 16 | - Accepting responsibility and apologizing to those affected by our mistakes, learning from the experience 17 | - Focusing on what is best not just for us as individuals, but for the overall community 18 | 19 | Examples of unacceptable behavior include: 20 | 21 | - The use of sexualized language or imagery, and any form of sexual attention or advances 22 | - Trolling, insulting, or derogatory comments, and personal or political attacks 23 | - Public or private harassment 24 | - Publishing others’ private information, such as physical or email addresses, without explicit permission 25 | - Other conduct that could reasonably be considered inappropriate in a professional setting 26 | 27 | ## Enforcement Responsibilities 28 | 29 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that do not align with this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 32 | 33 | ## Scope 34 | 35 | This Code of Conduct applies within all community spaces and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 36 | 37 | ## Enforcement 38 | 39 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement via [Discord](https://discord.gg/cGzUGurq). All complaints will be reviewed and investigated promptly and fairly. 40 | 41 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 42 | 43 | ## Enforcement Guidelines 44 | 45 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 46 | 47 | ### 1. Correction 48 | 49 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 50 | 51 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 52 | 53 | ### 2. Warning 54 | 55 | **Community Impact**: A violation through a single incident or a series of actions. 56 | 57 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 58 | 59 | ### 3. Temporary Ban 60 | 61 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 62 | 63 | **Consequence**: A temporary ban from any form of interaction or public communication with the community for a specified period. During this time, no public or private interaction with the people involved is allowed, including unsolicited interaction with those enforcing the Code of Conduct. Violating these terms may result in a permanent ban. 64 | 65 | ### 4. Permanent Ban 66 | 67 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of a group. 68 | 69 | **Consequence**: A permanent ban from any form of public interaction within the community. 70 | 71 | ## Attribution 72 | 73 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. 74 | 75 | Community Impact Guidelines were inspired by [Mozilla’s code of conduct enforcement ladder](https://github.com/mozilla/diversity). 76 | 77 | For answers to common questions about this Code of Conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guide 2 | 3 | Welcome to contribute! Please read this guide before participating. 4 | 5 | ## Development Environment Setup 6 | 7 | 1. Make sure you have the following software installed: 8 | - Visual Studio 2019 or higher 9 | - .NET Framework 4.8 (or the version specified by the project) 10 | - Revit API (depending on the target Revit version for the project) 11 | 12 | 2. Clone the repository: 13 | ```bash 14 | git clone https://github.com/revit-mcp/revit-mcp-commandset.git 15 | ``` 16 | 17 | 3. Open the solution file `revit-mcp-commandset.sln` in Visual Studio 18 | 19 | ## Code Contribution Process 20 | 21 | 1. Create a new branch from the latest `main` branch 22 | 2. Develop your feature or fix 23 | 3. Ensure the code compiles successfully and passes all tests 24 | 4. Commit with clear messages: [Consider following Conventional Commit Guidlines](https://www.conventionalcommits.org/en/v1.0.0/#summary) 25 | 5. Push the branch and create a Pull Request 26 | 27 | ## Branch Naming Conventions 28 | 29 | Branch naming should follow: 30 | - Feature branches: `feature/your-feature-name` 31 | - Fix branches: `fix/issue-description` 32 | - Documentation branches: `docs/update-description` 33 | 34 | ## Code Style 35 | 36 | - Follow C# coding conventions and existing code style 37 | - Use meaningful variable and function names 38 | - Add appropriate comments and documentation strings 39 | - Run code analysis tools before committing 40 | 41 | ## Commit Messages 42 | 43 | Use conventional commit formats: 44 | 45 | ``` 46 | feature: Add new feature 47 | fix: Fix bug 48 | docs: Update documentation 49 | refactor: Refactor code (no feature changes) 50 | test: Add tests 51 | ``` 52 | 53 | ## Reporting Issues 54 | 55 | - Search for existing issues before creating a new one 56 | - Provide detailed reproduction steps and environment information, including: 57 | - Revit version 58 | - Visual Studio version 59 | - Operating system version 60 | - Error logs (if available) 61 | 62 | ## Code of Conduct 63 | 64 | Please adhere to our [Code of Conduct](CODE_OF_CONDUCT.md) 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 revit-mcp-commandset 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # revit-mcp-commandset 2 | 🔄 Revit-MCP Client | Core implementation of the Revit-MCP protocol that connects LLMs with Revit. Includes essential CRUD commands for Revit elements enabling AI-driven BIM automation. 3 | -------------------------------------------------------------------------------- /revit-mcp-commandset.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.14.35906.104 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitMCPCommandSet", "revit-mcp-commandset\RevitMCPCommandSet.csproj", "{A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug R20|Any CPU = Debug R20|Any CPU 11 | Debug R21|Any CPU = Debug R21|Any CPU 12 | Debug R22|Any CPU = Debug R22|Any CPU 13 | Debug R23|Any CPU = Debug R23|Any CPU 14 | Debug R24|Any CPU = Debug R24|Any CPU 15 | Debug R25|Any CPU = Debug R25|Any CPU 16 | Release R20|Any CPU = Release R20|Any CPU 17 | Release R21|Any CPU = Release R21|Any CPU 18 | Release R22|Any CPU = Release R22|Any CPU 19 | Release R23|Any CPU = Release R23|Any CPU 20 | Release R24|Any CPU = Release R24|Any CPU 21 | Release R25|Any CPU = Release R25|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R20|Any CPU.ActiveCfg = Debug R20|Any CPU 25 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R20|Any CPU.Build.0 = Debug R20|Any CPU 26 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R21|Any CPU.ActiveCfg = Debug R21|Any CPU 27 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R21|Any CPU.Build.0 = Debug R21|Any CPU 28 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R22|Any CPU.ActiveCfg = Debug R22|Any CPU 29 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R22|Any CPU.Build.0 = Debug R22|Any CPU 30 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R23|Any CPU.ActiveCfg = Debug R23|Any CPU 31 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R23|Any CPU.Build.0 = Debug R23|Any CPU 32 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R24|Any CPU.ActiveCfg = Debug R24|Any CPU 33 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R24|Any CPU.Build.0 = Debug R24|Any CPU 34 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R25|Any CPU.ActiveCfg = Debug R25|Any CPU 35 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Debug R25|Any CPU.Build.0 = Debug R25|Any CPU 36 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R20|Any CPU.ActiveCfg = Release R20|Any CPU 37 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R20|Any CPU.Build.0 = Release R20|Any CPU 38 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R21|Any CPU.ActiveCfg = Release R21|Any CPU 39 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R21|Any CPU.Build.0 = Release R21|Any CPU 40 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R22|Any CPU.ActiveCfg = Release R22|Any CPU 41 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R22|Any CPU.Build.0 = Release R22|Any CPU 42 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R23|Any CPU.ActiveCfg = Release R23|Any CPU 43 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R23|Any CPU.Build.0 = Release R23|Any CPU 44 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R24|Any CPU.ActiveCfg = Release R24|Any CPU 45 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R24|Any CPU.Build.0 = Release R24|Any CPU 46 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R25|Any CPU.ActiveCfg = Release R25|Any CPU 47 | {A23E71AF-675B-41EE-9BD4-D4F3C8BA080D}.Release R25|Any CPU.Build.0 = Release R25|Any CPU 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {3852DD6D-1FB8-4C0E-AE54-0A8F2E8FA320} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/AIElementFilterCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPSDK.API.Base; 4 | using RevitMCPCommandSet.Models.Common; 5 | using RevitMCPCommandSet.Services; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace RevitMCPCommandSet.Commands 13 | { 14 | public class AIElementFilterCommand : ExternalEventCommandBase 15 | { 16 | private AIElementFilterEventHandler _handler => (AIElementFilterEventHandler)Handler; 17 | 18 | /// 19 | /// 命令名称 20 | /// 21 | public override string CommandName => "ai_element_filter"; 22 | 23 | /// 24 | /// 构造函数 25 | /// 26 | /// Revit UIApplication 27 | public AIElementFilterCommand(UIApplication uiApp) 28 | : base(new AIElementFilterEventHandler(), uiApp) 29 | { 30 | } 31 | 32 | public override object Execute(JObject parameters, string requestId) 33 | { 34 | try 35 | { 36 | FilterSetting data = new FilterSetting(); 37 | // 解析参数 38 | data = parameters["data"].ToObject(); 39 | if (data == null) 40 | throw new ArgumentNullException(nameof(data), "AI传入数据为空"); 41 | 42 | // 设置AI过滤器参数 43 | _handler.SetParameters(data); 44 | 45 | // 触发外部事件并等待完成 46 | if (RaiseAndWaitForCompletion(10000)) 47 | { 48 | return _handler.Result; 49 | } 50 | else 51 | { 52 | throw new TimeoutException("获取元素信息操作超时"); 53 | } 54 | } 55 | catch (Exception ex) 56 | { 57 | throw new Exception($"获取元素信息失败: {ex.Message}"); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/Access/GetAvailableFamilyTypesCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPCommandSet.Services; 4 | using RevitMCPSDK.API.Base; 5 | 6 | namespace RevitMCPCommandSet.Commands.Access 7 | { 8 | public class GetAvailableFamilyTypesCommand : ExternalEventCommandBase 9 | { 10 | private GetAvailableFamilyTypesEventHandler _handler => (GetAvailableFamilyTypesEventHandler)Handler; 11 | 12 | public override string CommandName => "get_available_family_types"; 13 | 14 | public GetAvailableFamilyTypesCommand(UIApplication uiApp) 15 | : base(new GetAvailableFamilyTypesEventHandler(), uiApp) 16 | { 17 | } 18 | 19 | public override object Execute(JObject parameters, string requestId) 20 | { 21 | try 22 | { 23 | // 解析参数 24 | List categoryList = parameters?["categoryList"]?.ToObject>() ?? new List(); 25 | string familyNameFilter = parameters?["familyNameFilter"]?.Value(); 26 | int? limit = parameters?["limit"]?.Value(); 27 | 28 | // 设置查询参数 29 | _handler.CategoryList = categoryList; 30 | _handler.FamilyNameFilter = familyNameFilter; 31 | _handler.Limit = limit; 32 | 33 | // 触发外部事件并等待完成,最多等待15秒 34 | if (RaiseAndWaitForCompletion(15000)) 35 | { 36 | return _handler.ResultFamilyTypes; 37 | } 38 | else 39 | { 40 | throw new TimeoutException("获取可用族类型超时"); 41 | } 42 | } 43 | catch (Exception ex) 44 | { 45 | throw new Exception($"获取可用族类型失败: {ex.Message}"); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/Access/GetCurrentViewElementsCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPCommandSet.Services; 4 | using RevitMCPSDK.API.Base; 5 | 6 | namespace RevitMCPCommandSet.Commands.Access 7 | { 8 | public class GetCurrentViewElementsCommand : ExternalEventCommandBase 9 | { 10 | private GetCurrentViewElementsEventHandler _handler => (GetCurrentViewElementsEventHandler)Handler; 11 | 12 | public override string CommandName => "get_current_view_elements"; 13 | 14 | public GetCurrentViewElementsCommand(UIApplication uiApp) 15 | : base(new GetCurrentViewElementsEventHandler(), uiApp) 16 | { 17 | } 18 | 19 | public override object Execute(JObject parameters, string requestId) 20 | { 21 | try 22 | { 23 | // 解析参数 24 | List modelCategoryList = parameters?["modelCategoryList"]?.ToObject>() ?? new List(); 25 | List annotationCategoryList = parameters?["annotationCategoryList"]?.ToObject>() ?? new List(); 26 | bool includeHidden = parameters?["includeHidden"]?.Value() ?? false; 27 | int limit = parameters?["limit"]?.Value() ?? 100; 28 | 29 | // 设置查询参数 30 | _handler.SetQueryParameters(modelCategoryList, annotationCategoryList, includeHidden, limit); 31 | 32 | // 触发外部事件并等待完成 33 | if (RaiseAndWaitForCompletion(60000)) // 60秒超时 34 | { 35 | return _handler.ResultInfo; 36 | } 37 | else 38 | { 39 | throw new TimeoutException("获取视图元素超时"); 40 | } 41 | } 42 | catch (Exception ex) 43 | { 44 | throw new Exception($"获取视图元素失败: {ex.Message}"); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/Access/GetCurrentViewInfoCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPCommandSet.Services; 4 | using RevitMCPSDK.API.Base; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace RevitMCPCommandSet.Commands.Access 13 | { 14 | public class GetCurrentViewInfoCommand : ExternalEventCommandBase 15 | { 16 | private GetCurrentViewInfoEventHandler _handler => (GetCurrentViewInfoEventHandler)Handler; 17 | 18 | public override string CommandName => "get_current_view_info"; 19 | 20 | public GetCurrentViewInfoCommand(UIApplication uiApp) 21 | : base(new GetCurrentViewInfoEventHandler(), uiApp) 22 | { 23 | } 24 | 25 | public override object Execute(JObject parameters, string requestId) 26 | { 27 | // 触发外部事件并等待完成 28 | if (RaiseAndWaitForCompletion(10000)) // 10秒超时 29 | { 30 | return _handler.ResultInfo; 31 | } 32 | else 33 | { 34 | throw new TimeoutException("获取信息超时"); 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/Access/GetSelectedElementsCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPCommandSet.Services; 4 | using RevitMCPSDK.API.Base; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Runtime.InteropServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace RevitMCPCommandSet.Commands.Access 13 | { 14 | public class GetSelectedElementsCommand : ExternalEventCommandBase 15 | { 16 | private GetSelectedElementsEventHandler _handler => (GetSelectedElementsEventHandler)Handler; 17 | 18 | public override string CommandName => "get_selected_elements"; 19 | 20 | public GetSelectedElementsCommand(UIApplication uiApp) 21 | : base(new GetSelectedElementsEventHandler(), uiApp) 22 | { 23 | } 24 | 25 | public override object Execute(JObject parameters, string requestId) 26 | { 27 | try 28 | { 29 | // 解析参数 30 | int? limit = parameters?["limit"]?.Value(); 31 | 32 | // 设置数量限制 33 | _handler.Limit = limit; 34 | 35 | // 触发外部事件并等待完成 36 | if (RaiseAndWaitForCompletion(15000)) 37 | { 38 | return _handler.ResultElements; 39 | } 40 | else 41 | { 42 | throw new TimeoutException("获取选中元素超时"); 43 | } 44 | } 45 | catch (Exception ex) 46 | { 47 | throw new Exception($"获取选中元素失败: {ex.Message}"); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/AnnotationComponents/CreateDimensionCommand.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Autodesk.Revit.UI; 25 | using Newtonsoft.Json.Linq; 26 | using RevitMCPSDK.API.Base; 27 | using RevitMCPCommandSet.Models.Annotation; 28 | using RevitMCPCommandSet.Services.AnnotationComponents; 29 | 30 | namespace RevitMCPCommandSet.Commands.AnnotationComponents; 31 | 32 | /// 33 | /// Command to create dimensions 34 | /// 35 | public class CreateDimensionCommand : ExternalEventCommandBase 36 | { 37 | /// 38 | /// Constructor 39 | /// 40 | /// Revit UIApplication 41 | public CreateDimensionCommand(UIApplication uiApp) 42 | : base(new CreateDimensionEventHandler(), uiApp) 43 | { 44 | } 45 | 46 | private CreateDimensionEventHandler _handler => (CreateDimensionEventHandler)Handler; 47 | 48 | /// 49 | /// Command name 50 | /// 51 | public override string CommandName => "create_dimensions"; 52 | 53 | /// 54 | /// Execute dimension creation command 55 | /// 56 | /// JSON parameters 57 | /// Request ID 58 | /// Execution result 59 | public override object Execute(JObject parameters, string requestId) 60 | { 61 | try 62 | { 63 | // Parse parameters 64 | var dimensions = parameters["dimensions"]?.ToObject>(); 65 | 66 | if (dimensions == null || dimensions.Count == 0) 67 | throw new ArgumentException("Dimension list cannot be empty"); 68 | 69 | // Set parameters and execute 70 | _handler.SetParameters(dimensions); 71 | 72 | // Raise event and wait for completion 73 | if (RaiseAndWaitForCompletion(20000)) // 20 seconds timeout 74 | return _handler.Result; 75 | throw new TimeoutException("Dimension creation operation timed out"); 76 | } 77 | catch (Exception ex) 78 | { 79 | throw new Exception($"Error creating dimensions: {ex.Message}", ex); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/ColorSplashCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPSDK.API.Base; 4 | using RevitMCPCommandSet.Services; 5 | 6 | namespace RevitMCPCommandSet.Commands 7 | { 8 | public class ColorSplashCommand : ExternalEventCommandBase 9 | { 10 | private ColorSplashEventHandler _handler => (ColorSplashEventHandler)Handler; 11 | 12 | /// 13 | /// Command name 14 | /// 15 | public override string CommandName => "color_splash"; 16 | 17 | /// 18 | /// Constructor 19 | /// 20 | /// Revit UIApplication 21 | public ColorSplashCommand(UIApplication uiApp) 22 | : base(new ColorSplashEventHandler(), uiApp) 23 | { 24 | } 25 | 26 | public override object Execute(JObject parameters, string requestId) 27 | { 28 | try 29 | { 30 | // Parse parameters 31 | string categoryName = null; 32 | if (parameters["categoryName"] != null) 33 | { 34 | categoryName = parameters["categoryName"].ToString(); 35 | } 36 | else 37 | { 38 | throw new ArgumentException("Category name is required"); 39 | } 40 | 41 | string parameterName = null; 42 | if (parameters["parameterName"] != null) 43 | { 44 | parameterName = parameters["parameterName"].ToString(); 45 | } 46 | else 47 | { 48 | throw new ArgumentException("Parameter name is required"); 49 | } 50 | 51 | bool useGradient = false; 52 | if (parameters["useGradient"] != null) 53 | { 54 | useGradient = parameters["useGradient"].ToObject(); 55 | } 56 | 57 | JArray customColors = null; 58 | if (parameters["customColors"] != null) 59 | { 60 | customColors = parameters["customColors"] as JArray; 61 | } 62 | 63 | // Set parameters for the event handler 64 | _handler.SetParameters(categoryName, parameterName, useGradient, customColors); 65 | 66 | // Trigger external event and wait for completion 67 | if (RaiseAndWaitForCompletion(20000)) // 20 second timeout 68 | { 69 | return _handler.ColoringResults; 70 | } 71 | else 72 | { 73 | throw new TimeoutException("Color splash operation timed out"); 74 | } 75 | } 76 | catch (Exception ex) 77 | { 78 | throw new Exception($"Color splash failed: {ex.Message}"); 79 | } 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/CreateLineElementCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPCommandSet.Models.Common; 4 | using RevitMCPCommandSet.Services; 5 | using RevitMCPSDK.API.Base; 6 | 7 | namespace RevitMCPCommandSet.Commands 8 | { 9 | public class CreateLineElementCommand : ExternalEventCommandBase 10 | { 11 | private CreateLineElementEventHandler _handler => (CreateLineElementEventHandler)Handler; 12 | 13 | /// 14 | /// 命令名称 15 | /// 16 | public override string CommandName => "create_line_based_element"; 17 | 18 | /// 19 | /// 构造函数 20 | /// 21 | /// Revit UIApplication 22 | public CreateLineElementCommand(UIApplication uiApp) 23 | : base(new CreateLineElementEventHandler(), uiApp) 24 | { 25 | } 26 | 27 | public override object Execute(JObject parameters, string requestId) 28 | { 29 | try 30 | { 31 | List data = new List(); 32 | // 解析参数 33 | data = parameters["data"].ToObject>(); 34 | if (data == null) 35 | throw new ArgumentNullException(nameof(data), "AI传入数据为空"); 36 | 37 | // 设置线状构件体参数 38 | _handler.SetParameters(data); 39 | 40 | // 触发外部事件并等待完成 41 | if (RaiseAndWaitForCompletion(10000)) 42 | { 43 | return _handler.Result; 44 | } 45 | else 46 | { 47 | throw new TimeoutException("创建线状构件操作超时"); 48 | } 49 | } 50 | catch (Exception ex) 51 | { 52 | throw new Exception($"创建线状构件失败: {ex.Message}"); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/CreatePointElementCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPSDK.API.Base; 4 | using RevitMCPCommandSet.Models.Common; 5 | using RevitMCPCommandSet.Services; 6 | 7 | namespace RevitMCPCommandSet.Commands 8 | { 9 | public class CreatePointElementCommand : ExternalEventCommandBase 10 | { 11 | private CreatePointElementEventHandler _handler => (CreatePointElementEventHandler)Handler; 12 | 13 | /// 14 | /// 命令名称 15 | /// 16 | public override string CommandName => "create_point_based_element"; 17 | 18 | /// 19 | /// 构造函数 20 | /// 21 | /// Revit UIApplication 22 | public CreatePointElementCommand(UIApplication uiApp) 23 | : base(new CreatePointElementEventHandler(), uiApp) 24 | { 25 | } 26 | 27 | public override object Execute(JObject parameters, string requestId) 28 | { 29 | try 30 | { 31 | List data = new List(); 32 | // 解析参数 33 | data = parameters["data"].ToObject>(); 34 | if (data == null) 35 | throw new ArgumentNullException(nameof(data), "AI传入数据为空"); 36 | 37 | // 设置点状构件体参数 38 | _handler.SetParameters(data); 39 | 40 | // 触发外部事件并等待完成 41 | if (RaiseAndWaitForCompletion(10000)) 42 | { 43 | return _handler.Result; 44 | } 45 | else 46 | { 47 | throw new TimeoutException("创建点状构件操作超时"); 48 | } 49 | } 50 | catch (Exception ex) 51 | { 52 | throw new Exception($"创建点状构件失败: {ex.Message}"); 53 | } 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/CreateSurfaceElementCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPSDK.API.Base; 4 | using RevitMCPCommandSet.Models.Common; 5 | using RevitMCPCommandSet.Services; 6 | 7 | namespace RevitMCPCommandSet.Commands 8 | { 9 | public class CreateSurfaceElementCommand : ExternalEventCommandBase 10 | { 11 | private CreateSurfaceElementEventHandler _handler => (CreateSurfaceElementEventHandler)Handler; 12 | 13 | /// 14 | /// 命令名称 15 | /// 16 | public override string CommandName => "create_surface_based_element"; 17 | 18 | /// 19 | /// 构造函数 20 | /// 21 | /// Revit UIApplication 22 | public CreateSurfaceElementCommand(UIApplication uiApp) 23 | : base(new CreateSurfaceElementEventHandler(), uiApp) 24 | { 25 | } 26 | 27 | public override object Execute(JObject parameters, string requestId) 28 | { 29 | try 30 | { 31 | List data = new List(); 32 | // 解析参数 33 | data = parameters["data"].ToObject>(); 34 | if (data == null) 35 | throw new ArgumentNullException(nameof(data), "AI传入数据为空"); 36 | 37 | // 设置面状构件体参数 38 | _handler.SetParameters(data); 39 | 40 | // 触发外部事件并等待完成 41 | if (RaiseAndWaitForCompletion(10000)) 42 | { 43 | return _handler.Result; 44 | } 45 | else 46 | { 47 | throw new TimeoutException("创建面状构件操作超时"); 48 | } 49 | } 50 | catch (Exception ex) 51 | { 52 | throw new Exception($"创建面状构件失败: {ex.Message}"); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/Delete/DeleteElementCommand.cs: -------------------------------------------------------------------------------- 1 | //using Autodesk.Revit.UI; 2 | //using Newtonsoft.Json.Linq; 3 | //using RevitMCPCommandSet.Services; 4 | //using RevitMCPSDK.API.Base; 5 | //using RevitMCPSDK.API.Models; 6 | //using RevitMCPSDK.Exceptions; 7 | 8 | //namespace RevitMCPCommandSet.Commands.Delete 9 | //{ 10 | // public class DeleteElementCommand : ExternalEventCommandBase 11 | // { 12 | // private DeleteElementEventHandler _handler => (DeleteElementEventHandler)Handler; 13 | // public override string CommandName => "delete_element"; 14 | // public DeleteElementCommand(UIApplication uiApp) 15 | // : base(new DeleteElementEventHandler(), uiApp) 16 | // { 17 | // } 18 | // public override object Execute(JObject parameters, string requestId) 19 | // { 20 | // try 21 | // { 22 | // // 解析数组参数 23 | // var elementIds = parameters?["elementIds"]?.ToObject(); 24 | // if (elementIds == null || elementIds.Length == 0) 25 | // { 26 | // throw new CommandExecutionException( 27 | // "元素ID列表不能为空", 28 | // JsonRPCErrorCodes.InvalidParams); 29 | // } 30 | // // 设置要删除的元素ID数组 31 | // _handler.ElementIds = elementIds; 32 | // // 触发外部事件并等待完成 33 | // if (RaiseAndWaitForCompletion(15000)) 34 | // { 35 | // if (_handler.IsSuccess) 36 | // { 37 | // return CommandResult.CreateSuccess(new { deleted = true, count = _handler.DeletedCount }); 38 | // } 39 | // else 40 | // { 41 | // throw new CommandExecutionException( 42 | // "删除元素失败", 43 | // JsonRPCErrorCodes.ElementDeletionFailed); 44 | // } 45 | // } 46 | // else 47 | // { 48 | // throw CreateTimeoutException(CommandName); 49 | // } 50 | // } 51 | // catch (CommandExecutionException) 52 | // { 53 | // throw; 54 | // } 55 | // catch (Exception ex) 56 | // { 57 | // throw new CommandExecutionException( 58 | // $"删除元素失败: {ex.Message}", 59 | // JsonRPCErrorCodes.InternalError); 60 | // } 61 | // } 62 | // } 63 | //} 64 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/ExecuteDynamicCode/ExecuteCodeCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPSDK.API.Base; 4 | 5 | namespace RevitMCPCommandSet.Commands.ExecuteDynamicCode 6 | { 7 | /// 8 | /// 处理代码执行的命令类 9 | /// 10 | public class ExecuteCodeCommand : ExternalEventCommandBase 11 | { 12 | private ExecuteCodeEventHandler _handler => (ExecuteCodeEventHandler)Handler; 13 | 14 | public override string CommandName => "send_code_to_revit"; 15 | 16 | public ExecuteCodeCommand(UIApplication uiApp) 17 | : base(new ExecuteCodeEventHandler(), uiApp) 18 | { 19 | } 20 | 21 | public override object Execute(JObject parameters, string requestId) 22 | { 23 | try 24 | { 25 | // 参数验证 26 | if (!parameters.ContainsKey("code")) 27 | { 28 | throw new ArgumentException("Missing required parameter: 'code'"); 29 | } 30 | 31 | // 解析代码和参数 32 | string code = parameters["code"].Value(); 33 | JArray parametersArray = parameters["parameters"] as JArray; 34 | object[] executionParameters = parametersArray?.ToObject() ?? Array.Empty(); 35 | 36 | // 设置执行参数 37 | _handler.SetExecutionParameters(code, executionParameters); 38 | 39 | // 触发外部事件并等待完成 40 | if (RaiseAndWaitForCompletion(60000)) // 1分钟超时 41 | { 42 | return _handler.ResultInfo; 43 | } 44 | else 45 | { 46 | throw new TimeoutException("代码执行超时"); 47 | } 48 | } 49 | catch (Exception ex) 50 | { 51 | throw new Exception($"执行代码失败: {ex.Message}", ex); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/ExecuteDynamicCode/ExecuteCodeEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System.CodeDom.Compiler; 2 | using Autodesk.Revit.UI; 3 | using Microsoft.CSharp; 4 | using Newtonsoft.Json; 5 | using RevitMCPSDK.API.Interfaces; 6 | 7 | namespace RevitMCPCommandSet.Commands.ExecuteDynamicCode 8 | { 9 | /// 10 | /// 处理代码执行的外部事件处理器 11 | /// 12 | public class ExecuteCodeEventHandler : IExternalEventHandler, IWaitableExternalEventHandler 13 | { 14 | // 代码执行参数 15 | private string _generatedCode; 16 | private object[] _executionParameters; 17 | 18 | // 执行结果信息 19 | public ExecutionResultInfo ResultInfo { get; private set; } 20 | 21 | // 状态同步对象 22 | public bool TaskCompleted { get; private set; } 23 | private readonly ManualResetEvent _resetEvent = new ManualResetEvent(false); 24 | 25 | // 设置要执行的代码和参数 26 | public void SetExecutionParameters(string code, object[] parameters = null) 27 | { 28 | _generatedCode = code; 29 | _executionParameters = parameters ?? Array.Empty(); 30 | TaskCompleted = false; 31 | _resetEvent.Reset(); 32 | } 33 | 34 | // 等待执行完成 - IWaitableExternalEventHandler接口实现 35 | public bool WaitForCompletion(int timeoutMilliseconds = 10000) 36 | { 37 | return _resetEvent.WaitOne(timeoutMilliseconds); 38 | } 39 | 40 | public void Execute(UIApplication app) 41 | { 42 | try 43 | { 44 | var doc = app.ActiveUIDocument.Document; 45 | ResultInfo = new ExecutionResultInfo(); 46 | 47 | using (var transaction = new Transaction(doc, "执行AI代码")) 48 | { 49 | transaction.Start(); 50 | 51 | // 动态编译执行代码 52 | var result = CompileAndExecuteCode( 53 | code: _generatedCode, 54 | doc: doc, 55 | parameters: _executionParameters 56 | ); 57 | 58 | transaction.Commit(); 59 | 60 | ResultInfo.Success = true; 61 | ResultInfo.Result = JsonConvert.SerializeObject(result); 62 | } 63 | } 64 | catch (Exception ex) 65 | { 66 | ResultInfo.Success = false; 67 | ResultInfo.ErrorMessage = $"执行失败: {ex.Message}"; 68 | } 69 | finally 70 | { 71 | TaskCompleted = true; 72 | _resetEvent.Set(); 73 | } 74 | } 75 | 76 | private object CompileAndExecuteCode(string code, Document doc, object[] parameters) 77 | { 78 | // 添加必要的程序集引用 79 | var compilerParams = new CompilerParameters 80 | { 81 | GenerateInMemory = true, 82 | GenerateExecutable = false, 83 | ReferencedAssemblies = 84 | { 85 | "System.dll", 86 | "System.Core.dll", 87 | typeof(Document).Assembly.Location, // RevitAPI.dll 88 | typeof(UIApplication).Assembly.Location // RevitAPIUI.dll 89 | } 90 | }; 91 | 92 | // 包装代码以规范入口点 93 | var wrappedCode = $@" 94 | using System; 95 | using Autodesk.Revit.DB; 96 | using Autodesk.Revit.UI; 97 | using System.Collections.Generic; 98 | 99 | namespace AIGeneratedCode 100 | {{ 101 | public static class CodeExecutor 102 | {{ 103 | public static object Execute(Document document, object[] parameters) 104 | {{ 105 | // 用户代码入口 106 | {code} 107 | }} 108 | }} 109 | }}"; 110 | 111 | // 编译代码 112 | using (var provider = new CSharpCodeProvider()) 113 | { 114 | var compileResults = provider.CompileAssemblyFromSource( 115 | compilerParams, 116 | wrappedCode 117 | ); 118 | 119 | // 处理编译结果 120 | if (compileResults.Errors.HasErrors) 121 | { 122 | var errors = string.Join("\n", compileResults.Errors 123 | .Cast() 124 | .Select(e => $"Line {e.Line}: {e.ErrorText}")); 125 | throw new Exception($"代码编译错误:\n{errors}"); 126 | } 127 | 128 | // 反射调用执行方法 129 | var assembly = compileResults.CompiledAssembly; 130 | var executorType = assembly.GetType("AIGeneratedCode.CodeExecutor"); 131 | var executeMethod = executorType.GetMethod("Execute"); 132 | 133 | return executeMethod.Invoke(null, new object[] { doc, parameters }); 134 | } 135 | } 136 | 137 | public string GetName() 138 | { 139 | return "执行AI代码"; 140 | } 141 | } 142 | 143 | // 执行结果数据结构 144 | public class ExecutionResultInfo 145 | { 146 | [JsonProperty("success")] 147 | public bool Success { get; set; } 148 | 149 | [JsonProperty("result")] 150 | public string Result { get; set; } 151 | 152 | [JsonProperty("errorMessage")] 153 | public string ErrorMessage { get; set; } = string.Empty; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/OperateElementCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPSDK.API.Base; 4 | using RevitMCPCommandSet.Models.Common; 5 | using RevitMCPCommandSet.Services; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace RevitMCPCommandSet.Commands 13 | { 14 | public class OperateElementCommand : ExternalEventCommandBase 15 | { 16 | private OperateElementEventHandler _handler => (OperateElementEventHandler)Handler; 17 | 18 | /// 19 | /// 命令名称 20 | /// 21 | public override string CommandName => "operate_element"; 22 | 23 | /// 24 | /// 构造函数 25 | /// 26 | /// Revit UIApplication 27 | public OperateElementCommand(UIApplication uiApp) 28 | : base(new OperateElementEventHandler(), uiApp) 29 | { 30 | } 31 | 32 | public override object Execute(JObject parameters, string requestId) 33 | { 34 | try 35 | { 36 | OperationSetting data = new OperationSetting(); 37 | // 解析参数 38 | data = parameters["data"].ToObject(); 39 | if (data == null) 40 | throw new ArgumentNullException(nameof(data), "AI传入数据为空"); 41 | 42 | // 设置点状构件体参数 43 | _handler.SetParameters(data); 44 | 45 | // 触发外部事件并等待完成 46 | if (RaiseAndWaitForCompletion(10000)) 47 | { 48 | return _handler.Result; 49 | } 50 | else 51 | { 52 | throw new TimeoutException("操作元素超时"); 53 | } 54 | } 55 | catch (Exception ex) 56 | { 57 | throw new Exception($"操作元素失败: {ex.Message}"); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Commands/TagWallsCommand.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using Newtonsoft.Json.Linq; 3 | using RevitMCPCommandSet.Services; 4 | using RevitMCPSDK.API.Base; 5 | 6 | namespace RevitMCPCommandSet.Commands 7 | { 8 | public class TagWallsCommand : ExternalEventCommandBase 9 | { 10 | private TagWallsEventHandler _handler => (TagWallsEventHandler)Handler; 11 | 12 | /// 13 | /// 命令名称 14 | /// 15 | public override string CommandName => "tag_walls"; 16 | 17 | /// 18 | /// 构造函数 19 | /// 20 | /// Revit UIApplication 21 | public TagWallsCommand(UIApplication uiApp) 22 | : base(new TagWallsEventHandler(), uiApp) 23 | { 24 | } 25 | 26 | public override object Execute(JObject parameters, string requestId) 27 | { 28 | try 29 | { 30 | // 解析参数 31 | bool useLeader = false; 32 | if (parameters["useLeader"] != null) 33 | { 34 | useLeader = parameters["useLeader"].ToObject(); 35 | } 36 | 37 | string tagTypeId = null; 38 | if (parameters["tagTypeId"] != null) 39 | { 40 | tagTypeId = parameters["tagTypeId"].ToString(); 41 | } 42 | 43 | // 设置标记参数 44 | _handler.SetParameters(useLeader, tagTypeId); 45 | 46 | // 触发外部事件并等待完成 47 | if (RaiseAndWaitForCompletion(10000)) 48 | { 49 | return _handler.TaggingResults; 50 | } 51 | else 52 | { 53 | throw new TimeoutException("标记墙操作超时"); 54 | } 55 | } 56 | catch (Exception ex) 57 | { 58 | throw new Exception($"标记墙失败: {ex.Message}"); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Annotation/DimensionCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Annotation; 28 | 29 | /// 30 | /// Information about dimension creation parameters 31 | /// 32 | public class DimensionCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public DimensionCreationInfo() 38 | { 39 | StartPoint = new JZPoint(0, 0, 0); 40 | EndPoint = new JZPoint(0, 0, 0); 41 | ElementIds = new List(); 42 | Options = new Dictionary(); 43 | } 44 | 45 | /// 46 | /// Dimension start point (mm) 47 | /// 48 | [JsonProperty("startPoint")] 49 | public JZPoint StartPoint { get; set; } 50 | 51 | /// 52 | /// Dimension end point (mm) 53 | /// 54 | [JsonProperty("endPoint")] 55 | public JZPoint EndPoint { get; set; } 56 | 57 | /// 58 | /// Dimension line point - location of dimension line (mm) 59 | /// 60 | [JsonProperty("linePoint")] 61 | public JZPoint LinePoint { get; set; } 62 | 63 | /// 64 | /// Elements to dimension 65 | /// 66 | [JsonProperty("elementIds")] 67 | public List ElementIds { get; set; } 68 | 69 | /// 70 | /// Dimension type 71 | /// 72 | [JsonProperty("dimensionType")] 73 | public string DimensionType { get; set; } = "Linear"; 74 | 75 | /// 76 | /// Dimension style ID 77 | /// 78 | [JsonProperty("dimensionStyleId")] 79 | public int DimensionStyleId { get; set; } = -1; 80 | 81 | /// 82 | /// View ID - view to create dimension in 83 | /// 84 | [JsonProperty("viewId")] 85 | public int ViewId { get; set; } = -1; 86 | 87 | /// 88 | /// Additional options 89 | /// 90 | [JsonProperty("options")] 91 | public Dictionary Options { get; set; } 92 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Annotation/TagCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Annotation; 28 | 29 | /// 30 | /// Information about tag creation parameters 31 | /// 32 | public class TagCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public TagCreationInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | Options = new Dictionary(); 41 | } 42 | 43 | /// 44 | /// Tag location point (mm) 45 | /// 46 | [JsonProperty("location")] 47 | public JZPoint Location { get; set; } 48 | 49 | /// 50 | /// Element ID to tag 51 | /// 52 | [JsonProperty("elementId")] 53 | public int ElementId { get; set; } = -1; 54 | 55 | /// 56 | /// Tag orientation (horizontal=0, vertical=1) 57 | /// 58 | [JsonProperty("orientation")] 59 | public int Orientation { get; set; } 60 | 61 | /// 62 | /// Tag rotation in degrees 63 | /// 64 | [JsonProperty("rotation")] 65 | public double Rotation { get; set; } 66 | 67 | /// 68 | /// Is tag leader visible 69 | /// 70 | [JsonProperty("hasLeader")] 71 | public bool HasLeader { get; set; } 72 | 73 | /// 74 | /// Tag type ID 75 | /// 76 | [JsonProperty("tagTypeId")] 77 | public int TagTypeId { get; set; } = -1; 78 | 79 | /// 80 | /// Tag category (Door, Window, Wall, etc.) 81 | /// 82 | [JsonProperty("tagCategory")] 83 | public string TagCategory { get; set; } = ""; 84 | 85 | /// 86 | /// View ID - view to create tag in 87 | /// 88 | [JsonProperty("viewId")] 89 | public int ViewId { get; set; } = -1; 90 | 91 | /// 92 | /// Additional options 93 | /// 94 | [JsonProperty("options")] 95 | public Dictionary Options { get; set; } 96 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Annotation/TextNoteCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Annotation; 28 | 29 | /// 30 | /// Information about text note creation parameters 31 | /// 32 | public class TextNoteCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public TextNoteCreationInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | Options = new Dictionary(); 41 | } 42 | 43 | /// 44 | /// Text note location point (mm) 45 | /// 46 | [JsonProperty("location")] 47 | public JZPoint Location { get; set; } 48 | 49 | /// 50 | /// Text content 51 | /// 52 | [JsonProperty("text")] 53 | public string Text { get; set; } = ""; 54 | 55 | /// 56 | /// Text rotation in degrees 57 | /// 58 | [JsonProperty("rotation")] 59 | public double Rotation { get; set; } 60 | 61 | /// 62 | /// Text width (mm) - if zero, no width limit 63 | /// 64 | [JsonProperty("width")] 65 | public double Width { get; set; } 66 | 67 | /// 68 | /// Text note type ID 69 | /// 70 | [JsonProperty("textNoteTypeId")] 71 | public int TextNoteTypeId { get; set; } = -1; 72 | 73 | /// 74 | /// View ID - view to create text note in 75 | /// 76 | [JsonProperty("viewId")] 77 | public int ViewId { get; set; } = -1; 78 | 79 | /// 80 | /// Text horizontal alignment (Left=0, Center=1, Right=2) 81 | /// 82 | [JsonProperty("horizontalAlign")] 83 | public int HorizontalAlign { get; set; } 84 | 85 | /// 86 | /// Text vertical alignment (Top=0, Middle=1, Bottom=2) 87 | /// 88 | [JsonProperty("verticalAlign")] 89 | public int VerticalAlign { get; set; } 90 | 91 | /// 92 | /// Additional options 93 | /// 94 | [JsonProperty("options")] 95 | public Dictionary Options { get; set; } 96 | } 97 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/AreaCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | 25 | using Newtonsoft.Json; 26 | using RevitMCPCommandSet.Models.Common; 27 | 28 | namespace RevitMCPCommandSet.Models.Architecture; 29 | 30 | /// 31 | /// Information about area creation parameters 32 | /// 33 | public class AreaCreationInfo 34 | { 35 | /// 36 | /// Default constructor 37 | /// 38 | public AreaCreationInfo() 39 | { 40 | Location = new JZPoint(0, 0, 0); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Area location point (mm) 46 | /// 47 | [JsonProperty("location")] 48 | public JZPoint Location { get; set; } 49 | 50 | /// 51 | /// Area name 52 | /// 53 | [JsonProperty("name")] 54 | public string Name { get; set; } = "Area"; 55 | 56 | /// 57 | /// Area level ID in Revit 58 | /// 59 | [JsonProperty("levelId")] 60 | public int LevelId { get; set; } 61 | 62 | /// 63 | /// Level elevation (mm) 64 | /// 65 | [JsonProperty("level")] 66 | public double Level { get; set; } 67 | 68 | /// 69 | /// Area scheme ID in Revit 70 | /// 71 | [JsonProperty("areaSchemeId")] 72 | public int AreaSchemeId { get; set; } 73 | 74 | /// 75 | /// Area scheme name 76 | /// 77 | [JsonProperty("areaScheme")] 78 | public string AreaScheme { get; set; } 79 | 80 | /// 81 | /// Area view ID in Revit 82 | /// 83 | [JsonProperty("areaViewId")] 84 | public int AreaViewId { get; set; } 85 | 86 | /// 87 | /// Additional options 88 | /// 89 | [JsonProperty("options")] 90 | public Dictionary Options { get; set; } 91 | } 92 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/BalconyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about a balcony 31 | /// 32 | public class BalconyInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public BalconyInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | } 41 | 42 | /// 43 | /// Constructor with position and dimensions 44 | /// 45 | /// X position (mm) 46 | /// Y position (mm) 47 | /// Z position (mm) 48 | /// Width (mm) 49 | /// Depth (mm) 50 | /// Floor elevation (mm) 51 | public BalconyInfo(double x, double y, double z, double width, double depth, double level = 0) 52 | { 53 | Location = new JZPoint(x, y, z); 54 | Width = width; 55 | Depth = depth; 56 | Level = level; 57 | } 58 | 59 | /// 60 | /// Balcony corner position (mm) 61 | /// 62 | [JsonProperty("location")] 63 | public JZPoint Location { get; set; } 64 | 65 | /// 66 | /// Balcony width (mm) 67 | /// 68 | [JsonProperty("width")] 69 | public double Width { get; set; } 70 | 71 | /// 72 | /// Balcony length (mm) - projection distance from wall 73 | /// 74 | [JsonProperty("depth")] 75 | public double Depth { get; set; } 76 | 77 | /// 78 | /// Balcony floor thickness (mm) 79 | /// 80 | [JsonProperty("thickness")] 81 | public double Thickness { get; set; } 82 | 83 | /// 84 | /// Host floor elevation (mm) 85 | /// 86 | [JsonProperty("level")] 87 | public double Level { get; set; } 88 | 89 | /// 90 | /// Host wall for the balcony (reference ID) 91 | /// 92 | [JsonProperty("hostWallId")] 93 | public string HostWallId { get; set; } 94 | 95 | /// 96 | /// Railing type 97 | /// 98 | [JsonProperty("railingType")] 99 | public string RailingType { get; set; } // Glass, Metal, etc. 100 | 101 | /// 102 | /// Railing height (mm) 103 | /// 104 | [JsonProperty("railingHeight")] 105 | public double RailingHeight { get; set; } 106 | 107 | /// 108 | /// Balcony floor material 109 | /// 110 | [JsonProperty("floorMaterial")] 111 | public string FloorMaterial { get; set; } 112 | 113 | /// 114 | /// Railing material 115 | /// 116 | [JsonProperty("railingMaterial")] 117 | public string RailingMaterial { get; set; } 118 | 119 | /// 120 | /// Additional options 121 | /// 122 | [JsonProperty("options")] 123 | public Dictionary Options { get; set; } = new(); 124 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/BeamInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about a structural beam 31 | /// 32 | public class BeamInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public BeamInfo() 38 | { 39 | StartPoint = new JZPoint(0, 0, 0); 40 | EndPoint = new JZPoint(0, 0, 0); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with position and dimensions 46 | /// 47 | /// Start X position (mm) 48 | /// Start Y position (mm) 49 | /// Start Z position (mm) 50 | /// End X position (mm) 51 | /// End Y position (mm) 52 | /// End Z position (mm) 53 | /// Width (mm) 54 | /// Height (mm) 55 | /// Level elevation (mm) 56 | public BeamInfo(double startX, double startY, double startZ, double endX, double endY, double endZ, 57 | double width, double height, double level = 0) 58 | { 59 | StartPoint = new JZPoint(startX, startY, startZ); 60 | EndPoint = new JZPoint(endX, endY, endZ); 61 | Width = width; 62 | Height = height; 63 | Level = level; 64 | } 65 | 66 | /// 67 | /// Beam start position (mm) 68 | /// 69 | [JsonProperty("startPoint")] 70 | public JZPoint StartPoint { get; set; } 71 | 72 | /// 73 | /// Beam end position (mm) 74 | /// 75 | [JsonProperty("endPoint")] 76 | public JZPoint EndPoint { get; set; } 77 | 78 | /// 79 | /// Beam width (mm) 80 | /// 81 | [JsonProperty("width")] 82 | public double Width { get; set; } = 300; 83 | 84 | /// 85 | /// Beam height (mm) 86 | /// 87 | [JsonProperty("height")] 88 | public double Height { get; set; } = 500; 89 | 90 | /// 91 | /// Host level elevation (mm) 92 | /// 93 | [JsonProperty("level")] 94 | public double Level { get; set; } 95 | 96 | /// 97 | /// Beam offset from level (mm) 98 | /// 99 | [JsonProperty("levelOffset")] 100 | public double LevelOffset { get; set; } 101 | 102 | /// 103 | /// Beam type 104 | /// 105 | [JsonProperty("type")] 106 | public string Type { get; set; } = "Concrete"; // Concrete, Steel, Wood, etc. 107 | 108 | /// 109 | /// Beam family type ID in Revit 110 | /// 111 | [JsonProperty("typeId")] 112 | public int TypeId { get; set; } = -1; 113 | 114 | /// 115 | /// Beam material 116 | /// 117 | [JsonProperty("material")] 118 | public string Material { get; set; } = "Concrete"; 119 | 120 | /// 121 | /// Structural parameters: Is load-bearing 122 | /// 123 | [JsonProperty("isLoadBearing")] 124 | public bool IsLoadBearing { get; set; } = true; 125 | 126 | /// 127 | /// Additional options 128 | /// 129 | [JsonProperty("options")] 130 | public Dictionary Options { get; set; } 131 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/BuildingInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Overall description of a building 31 | /// 32 | public class BuildingInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public BuildingInfo() 38 | { 39 | // Initialize roof information 40 | Roof = new RoofInfo(); 41 | } 42 | 43 | /// 44 | /// Create a basic building structure with given dimensions 45 | /// 46 | /// Width (mm) 47 | /// Length (mm) 48 | /// Height (mm) 49 | /// Number of floors 50 | public BuildingInfo(double width, double length, double height, int floorCount = 1) 51 | { 52 | Width = width; 53 | Length = length; 54 | Height = height; 55 | FloorCount = floorCount; 56 | } 57 | 58 | /// 59 | /// Building name 60 | /// 61 | [JsonProperty("name")] 62 | public string Name { get; set; } = "Building"; 63 | 64 | /// 65 | /// Building description 66 | /// 67 | [JsonProperty("description")] 68 | public string Description { get; set; } = ""; 69 | 70 | /// 71 | /// Overall width (mm) 72 | /// 73 | [JsonProperty("width")] 74 | public double Width { get; set; } 75 | 76 | /// 77 | /// Overall length (mm) 78 | /// 79 | [JsonProperty("length")] 80 | public double Length { get; set; } 81 | 82 | /// 83 | /// Overall height (mm) 84 | /// 85 | [JsonProperty("height")] 86 | public double Height { get; set; } 87 | 88 | /// 89 | /// Number of floors 90 | /// 91 | [JsonProperty("floorCount")] 92 | public int FloorCount { get; set; } 93 | 94 | /// 95 | /// Height per floor (mm) 96 | /// 97 | [JsonProperty("floorHeight")] 98 | public double FloorHeight { get; set; } 99 | 100 | /// 101 | /// Roof type 102 | /// 103 | [JsonProperty("roofType")] 104 | public string RoofType { get; set; } // Flat, Gable, Hip, etc. 105 | 106 | /// 107 | /// Information about floors 108 | /// 109 | [JsonProperty("floors")] 110 | public List Floors { get; set; } = new(); 111 | 112 | /// 113 | /// List of walls 114 | /// 115 | [JsonProperty("walls")] 116 | public List Walls { get; set; } = new(); 117 | 118 | /// 119 | /// List of doors 120 | /// 121 | [JsonProperty("doors")] 122 | public List Doors { get; set; } = new(); 123 | 124 | /// 125 | /// List of windows 126 | /// 127 | [JsonProperty("windows")] 128 | public List Windows { get; set; } = new(); 129 | 130 | /// 131 | /// List of balconies 132 | /// 133 | [JsonProperty("balconies")] 134 | public List Balconies { get; set; } = new(); 135 | 136 | /// 137 | /// Roof information 138 | /// 139 | [JsonProperty("roof")] 140 | public RoofInfo Roof { get; set; } 141 | 142 | /// 143 | /// Materials for components 144 | /// 145 | [JsonProperty("materials")] 146 | public Dictionary Materials { get; set; } = new(); 147 | 148 | /// 149 | /// Additional options 150 | /// 151 | [JsonProperty("options")] 152 | public Dictionary Options { get; set; } = new(); 153 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/CeilingCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about ceiling creation parameters 31 | /// 32 | public class CeilingCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public CeilingCreationInfo() 38 | { 39 | BoundaryPoints = new List(); 40 | Openings = new List>(); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with basic parameters 46 | /// 47 | /// Base level elevation (mm) 48 | /// Ceiling thickness (mm) 49 | /// List of boundary points forming ceiling outline 50 | public CeilingCreationInfo(double level, double thickness, List boundaryPoints) 51 | { 52 | Level = level; 53 | Thickness = thickness; 54 | BoundaryPoints = boundaryPoints ?? new List(); 55 | Openings = new List>(); 56 | Options = new Dictionary(); 57 | } 58 | 59 | /// 60 | /// Base level elevation (mm) 61 | /// 62 | [JsonProperty("level")] 63 | public double Level { get; set; } 64 | 65 | /// 66 | /// Ceiling thickness (mm) 67 | /// 68 | [JsonProperty("thickness")] 69 | public double Thickness { get; set; } 70 | 71 | /// 72 | /// Ceiling boundary points (mm) 73 | /// 74 | [JsonProperty("boundaryPoints")] 75 | public List BoundaryPoints { get; set; } 76 | 77 | /// 78 | /// Holes/openings in the ceiling (list of boundary loops) 79 | /// 80 | [JsonProperty("openings")] 81 | public List> Openings { get; set; } 82 | 83 | /// 84 | /// Level offset (mm) - how far above the level 85 | /// 86 | [JsonProperty("levelOffset")] 87 | public double LevelOffset { get; set; } 88 | 89 | /// 90 | /// Ceiling type ID in Revit 91 | /// 92 | [JsonProperty("typeId")] 93 | public int TypeId { get; set; } 94 | 95 | /// 96 | /// Ceiling type name 97 | /// 98 | [JsonProperty("ceilingType")] 99 | public string CeilingType { get; set; } 100 | 101 | /// 102 | /// Ceiling material 103 | /// 104 | [JsonProperty("material")] 105 | public string Material { get; set; } 106 | 107 | /// 108 | /// Additional options 109 | /// 110 | [JsonProperty("options")] 111 | public Dictionary Options { get; set; } 112 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/ColumnInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about a structural column 31 | /// 32 | public class ColumnInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public ColumnInfo() 38 | { 39 | Options = new Dictionary(); 40 | } 41 | 42 | /// 43 | /// Constructor with position and dimensions 44 | /// 45 | /// X position (mm) 46 | /// Y position (mm) 47 | /// Z position (mm) 48 | /// Width (mm) 49 | /// Depth (mm) 50 | /// Height (mm) 51 | /// Base level elevation (mm) 52 | public ColumnInfo(double x, double y, double z, double width, double depth, double height, double baseLevel) 53 | { 54 | Location = new JZPoint(x, y, z); 55 | Width = width; 56 | Depth = depth; 57 | Height = height; 58 | BaseLevel = baseLevel; 59 | } 60 | 61 | /// 62 | /// Column position (mm) 63 | /// 64 | [JsonProperty("location")] 65 | public JZPoint Location { get; set; } 66 | 67 | /// 68 | /// Column width (mm) 69 | /// 70 | [JsonProperty("width")] 71 | public double Width { get; set; } 72 | 73 | /// 74 | /// Column depth (mm) 75 | /// 76 | [JsonProperty("depth")] 77 | public double Depth { get; set; } 78 | 79 | /// 80 | /// Column height (mm) 81 | /// 82 | [JsonProperty("height")] 83 | public double Height { get; set; } 84 | 85 | /// 86 | /// Base level elevation (mm) 87 | /// 88 | [JsonProperty("baseLevel")] 89 | public double BaseLevel { get; set; } 90 | 91 | /// 92 | /// Top level elevation (mm) 93 | /// 94 | [JsonProperty("topLevel")] 95 | public double TopLevel { get; set; } 96 | 97 | /// 98 | /// Column rotation (degrees) 99 | /// 100 | [JsonProperty("rotation")] 101 | public double Rotation { get; set; } 102 | 103 | /// 104 | /// Column type 105 | /// 106 | [JsonProperty("type")] 107 | public string Type { get; set; } 108 | 109 | /// 110 | /// Column family type ID in Revit 111 | /// 112 | [JsonProperty("typeId")] 113 | public int TypeId { get; set; } 114 | 115 | /// 116 | /// Column material 117 | /// 118 | [JsonProperty("material")] 119 | public string Material { get; set; } 120 | 121 | /// 122 | /// Column diameter (for circular columns, mm) 123 | /// 124 | [JsonProperty("diameter")] 125 | public double Diameter { get; set; } 126 | 127 | /// 128 | /// Is structural 129 | /// 130 | [JsonProperty("isStructural")] 131 | public bool IsStructural { get; set; } 132 | 133 | /// 134 | /// Additional options 135 | /// 136 | [JsonProperty("options")] 137 | public Dictionary Options { get; set; } 138 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/DoorInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about a door 31 | /// 32 | public class DoorInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public DoorInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | } 41 | 42 | /// 43 | /// Constructor with position and dimensions 44 | /// 45 | /// X position (mm) 46 | /// Y position (mm) 47 | /// Z position (mm) 48 | /// Width (mm) 49 | /// Height (mm) 50 | /// Floor elevation (mm) 51 | public DoorInfo(double x, double y, double z, double width, double height, double level = 0) 52 | { 53 | Location = new JZPoint(x, y, z); 54 | Width = width; 55 | Height = height; 56 | Level = level; 57 | } 58 | 59 | /// 60 | /// Door position (mm) 61 | /// 62 | [JsonProperty("location")] 63 | public JZPoint Location { get; set; } 64 | 65 | /// 66 | /// Host wall for the door (reference ID) 67 | /// 68 | [JsonProperty("hostWallId")] 69 | public string HostWallId { get; set; } 70 | 71 | /// 72 | /// Door width (mm) 73 | /// 74 | [JsonProperty("width")] 75 | public double Width { get; set; } 76 | 77 | /// 78 | /// Door height (mm) 79 | /// 80 | [JsonProperty("height")] 81 | public double Height { get; set; } 82 | 83 | /// 84 | /// Height from floor (mm) 85 | /// 86 | [JsonProperty("elevation")] 87 | public double Elevation { get; set; } 88 | 89 | /// 90 | /// Host floor elevation (mm) 91 | /// 92 | [JsonProperty("level")] 93 | public double Level { get; set; } 94 | 95 | /// 96 | /// Door type 97 | /// 98 | [JsonProperty("type")] 99 | public string Type { get; set; } // Single, Double, Sliding, etc. 100 | 101 | /// 102 | /// Door type ID in Revit 103 | /// 104 | [JsonProperty("typeId")] 105 | public int TypeId { get; set; } 106 | 107 | /// 108 | /// Door material 109 | /// 110 | [JsonProperty("material")] 111 | public string Material { get; set; } 112 | 113 | /// 114 | /// Door opening angle (degrees) 115 | /// 116 | [JsonProperty("openingAngle")] 117 | public double OpeningAngle { get; set; } 118 | 119 | /// 120 | /// Additional options 121 | /// 122 | [JsonProperty("options")] 123 | public Dictionary Options { get; set; } = new(); 124 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/FloorInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about a floor in Revit, used for both creation and retrieval 31 | /// 32 | public class FloorInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public FloorInfo() 38 | { 39 | BoundaryPoints = new List(); 40 | Openings = new List>(); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with basic parameters 46 | /// 47 | /// Base level elevation (mm) 48 | /// Floor thickness (mm) 49 | /// List of boundary points forming floor outline 50 | public FloorInfo(double level, double thickness, List boundaryPoints) 51 | { 52 | Level = level; 53 | Thickness = thickness; 54 | BoundaryPoints = boundaryPoints ?? new List(); 55 | Openings = new List>(); 56 | Options = new Dictionary(); 57 | } 58 | 59 | /// 60 | /// Element ID 61 | /// 62 | [JsonProperty("elementId")] 63 | public int ElementId { get; set; } 64 | 65 | /// 66 | /// Floor name 67 | /// 68 | [JsonProperty("name")] 69 | public string Name { get; set; } = "Floor"; 70 | 71 | /// 72 | /// Base level elevation (mm) 73 | /// 74 | [JsonProperty("level")] 75 | public double Level { get; set; } 76 | 77 | /// 78 | /// Floor height (mm) - the vertical dimension of the floor space 79 | /// 80 | [JsonProperty("height")] 81 | public double Height { get; set; } 82 | 83 | /// 84 | /// Floor thickness (mm) - the physical thickness of the floor element 85 | /// 86 | [JsonProperty("thickness")] 87 | public double Thickness { get; set; } 88 | 89 | /// 90 | /// Floor boundary points (mm) 91 | /// 92 | [JsonProperty("boundaryPoints")] 93 | public List BoundaryPoints { get; set; } 94 | 95 | /// 96 | /// Holes/openings in the floor (list of boundary loops) 97 | /// 98 | [JsonProperty("openings")] 99 | public List> Openings { get; set; } 100 | 101 | /// 102 | /// Level offset (mm) 103 | /// 104 | [JsonProperty("levelOffset")] 105 | public double LevelOffset { get; set; } 106 | 107 | /// 108 | /// Floor type ID in Revit 109 | /// 110 | [JsonProperty("typeId")] 111 | public int TypeId { get; set; } = -1; 112 | 113 | /// 114 | /// Floor type name 115 | /// 116 | [JsonProperty("floorType")] 117 | public string FloorType { get; set; } 118 | 119 | /// 120 | /// Floor material 121 | /// 122 | [JsonProperty("material")] 123 | public string Material { get; set; } 124 | 125 | /// 126 | /// Floor level name 127 | /// 128 | [JsonProperty("levelName")] 129 | public string LevelName { get; set; } 130 | 131 | /// 132 | /// Is floor structural 133 | /// 134 | [JsonProperty("isStructural")] 135 | public bool IsStructural { get; set; } 136 | 137 | /// 138 | /// Floor area (m²) 139 | /// 140 | [JsonProperty("area")] 141 | public double Area { get; set; } 142 | 143 | /// 144 | /// Additional options 145 | /// 146 | [JsonProperty("options")] 147 | public Dictionary Options { get; set; } 148 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/FoundationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | public class FoundationInfo 30 | { 31 | /// 32 | /// Type of foundation (e.g., "Isolated", "Strip", "Raft", "Pile") 33 | /// 34 | [JsonProperty("type")] 35 | public string Type { get; set; } = "Isolated"; 36 | 37 | /// 38 | /// Location of the foundation in millimeters (X, Y, Z coordinates) 39 | /// 40 | [JsonProperty("location")] 41 | public JZPoint Location { get; set; } = new(); 42 | 43 | /// 44 | /// Width of the foundation in millimeters 45 | /// 46 | [JsonProperty("width")] 47 | public double Width { get; set; } 48 | 49 | /// 50 | /// Length of the foundation in millimeters 51 | /// 52 | [JsonProperty("length")] 53 | public double Length { get; set; } 54 | 55 | /// 56 | /// Thickness/depth of the foundation in millimeters 57 | /// 58 | [JsonProperty("thickness")] 59 | public double Thickness { get; set; } 60 | 61 | /// 62 | /// Elevation of the foundation in millimeters 63 | /// 64 | [JsonProperty("elevation")] 65 | public double Elevation { get; set; } 66 | 67 | /// 68 | /// Material of the foundation 69 | /// 70 | [JsonProperty("material")] 71 | public string Material { get; set; } 72 | 73 | /// 74 | /// Optional ID of the column or wall supported by this foundation 75 | /// 76 | [JsonProperty("supportedElementId")] 77 | public int SupportedElementId { get; set; } 78 | 79 | /// 80 | /// Optional rotation angle in degrees 81 | /// 82 | [JsonProperty("rotation")] 83 | public double Rotation { get; set; } 84 | 85 | /// 86 | /// Optional parameter for strip foundation - path points 87 | /// 88 | [JsonProperty("path")] 89 | public List Path { get; set; } = new(); 90 | 91 | /// 92 | /// Optional parameter for pile foundation - depth 93 | /// 94 | [JsonProperty("depth")] 95 | public double Depth { get; set; } 96 | 97 | /// 98 | /// Optional parameter for pile foundation - diameter 99 | /// 100 | [JsonProperty("diameter")] 101 | public double Diameter { get; set; } 102 | 103 | /// 104 | /// Optional parameter for raft foundation - boundary points 105 | /// 106 | [JsonProperty("boundary")] 107 | public List Boundary { get; set; } = new(); 108 | 109 | /// 110 | /// Optional parameter for family type ID 111 | /// 112 | [JsonProperty("typeId")] 113 | public int TypeId { get; set; } 114 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/GridInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitMCPCommandSet.Models.Architecture; 4 | 5 | public class GridInfo 6 | { 7 | /// 8 | /// X-axis grid line positions in millimeters 9 | /// 10 | [JsonProperty("xAxis")] 11 | public List XAxis { get; set; } = new(); 12 | 13 | /// 14 | /// Y-axis grid line positions in millimeters 15 | /// 16 | [JsonProperty("yAxis")] 17 | public List YAxis { get; set; } = new(); 18 | 19 | /// 20 | /// Optional labels for X-axis grid lines 21 | /// 22 | [JsonProperty("xLabels")] 23 | public List XLabels { get; set; } = new(); 24 | 25 | /// 26 | /// Optional labels for Y-axis grid lines 27 | /// 28 | [JsonProperty("yLabels")] 29 | public List YLabels { get; set; } = new(); 30 | 31 | /// 32 | /// Optional Z-coordinate for the grid system in millimeters 33 | /// 34 | [JsonProperty("elevation")] 35 | public double Elevation { get; set; } 36 | 37 | /// 38 | /// Optional parameter to indicate if the grid system should extend to 3D 39 | /// 40 | [JsonProperty("extendTo3D")] 41 | public bool ExtendTo3D { get; set; } 42 | 43 | /// 44 | /// Optional parameter to specify the height of 3D grid lines in millimeters 45 | /// 46 | [JsonProperty("extendHeight")] 47 | public double ExtendHeight { get; set; } 48 | 49 | /// 50 | /// Optional parameter to specify the bubble visibility 51 | /// 52 | [JsonProperty("bubbleVisible")] 53 | public bool BubbleVisible { get; set; } = true; 54 | 55 | /// 56 | /// Optional parameter to specify the grid line weight 57 | /// 58 | [JsonProperty("lineWeight")] 59 | public int LineWeight { get; set; } 60 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/GroupCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Architecture; 27 | 28 | /// 29 | /// Information for group creation from elements 30 | /// 31 | public class GroupCreationInfo 32 | { 33 | /// 34 | /// Default constructor 35 | /// 36 | public GroupCreationInfo() 37 | { 38 | ElementIds = new List(); 39 | } 40 | 41 | /// 42 | /// Name for the new group 43 | /// 44 | [JsonProperty("name")] 45 | public string Name { get; set; } = string.Empty; 46 | 47 | /// 48 | /// Element IDs to include in the group 49 | /// 50 | [JsonProperty("elementIds")] 51 | public List ElementIds { get; set; } 52 | } 53 | 54 | /// 55 | /// Information for placing a group instance 56 | /// 57 | public class GroupInstanceInfo 58 | { 59 | /// 60 | /// Group type ID to place 61 | /// 62 | [JsonProperty("groupTypeId")] 63 | public int GroupTypeId { get; set; } 64 | 65 | /// 66 | /// Insertion point for the group (millimeters) 67 | /// 68 | [JsonProperty("insertionPoint")] 69 | public Point InsertionPoint { get; set; } 70 | 71 | /// 72 | /// Rotation angle in degrees 73 | /// 74 | [JsonProperty("rotation")] 75 | public double Rotation { get; set; } 76 | 77 | /// 78 | /// Mirror the group about X axis 79 | /// 80 | [JsonProperty("mirrorAboutX")] 81 | public bool MirrorAboutX { get; set; } 82 | 83 | /// 84 | /// Mirror the group about Y axis 85 | /// 86 | [JsonProperty("mirrorAboutY")] 87 | public bool MirrorAboutY { get; set; } 88 | } 89 | 90 | /// 91 | /// Result of group creation or placement 92 | /// 93 | public class GroupResult 94 | { 95 | /// 96 | /// Group instance ID 97 | /// 98 | [JsonProperty("groupId")] 99 | public int GroupId { get; set; } 100 | 101 | /// 102 | /// Group type ID 103 | /// 104 | [JsonProperty("groupTypeId")] 105 | public int GroupTypeId { get; set; } 106 | 107 | /// 108 | /// Group name 109 | /// 110 | [JsonProperty("name")] 111 | public string Name { get; set; } = string.Empty; 112 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/LevelInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Architecture; 27 | 28 | public class LevelInfo 29 | { 30 | /// 31 | /// Name of the level 32 | /// 33 | [JsonProperty("name")] 34 | public string Name { get; set; } 35 | 36 | /// 37 | /// Elevation of the level in millimeters 38 | /// 39 | [JsonProperty("elevation")] 40 | public double Elevation { get; set; } 41 | 42 | /// 43 | /// Optional description of the level 44 | /// 45 | [JsonProperty("description")] 46 | public string Description { get; set; } 47 | 48 | /// 49 | /// Optional parameter to indicate if this is a main level 50 | /// 51 | [JsonProperty("isMainLevel")] 52 | public bool IsMainLevel { get; set; } = true; 53 | 54 | /// 55 | /// Optional parameter to indicate if this level should be used for building story 56 | /// 57 | [JsonProperty("isBuildingStory")] 58 | public bool IsBuildingStory { get; set; } = true; 59 | 60 | /// 61 | /// Optional parameter to indicate if this level should be used for computation 62 | /// 63 | [JsonProperty("computationHeight")] 64 | public double ComputationHeight { get; set; } 65 | 66 | /// 67 | /// Optional parameter to indicate if this level should be used for view plan 68 | /// 69 | [JsonProperty("viewPlanOffset")] 70 | public double ViewPlanOffset { get; set; } 71 | 72 | /// 73 | /// Optional parameter to indicate if this level should be used for view section 74 | /// 75 | [JsonProperty("viewSectionOffset")] 76 | public double ViewSectionOffset { get; set; } 77 | 78 | /// 79 | /// Optional parameter to indicate if this level should be used for view elevation 80 | /// 81 | [JsonProperty("viewElevationOffset")] 82 | public double ViewElevationOffset { get; set; } 83 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/ModelCurveCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Architecture; 27 | 28 | /// 29 | /// Information for model curve creation 30 | /// 31 | public class ModelCurveCreationInfo 32 | { 33 | /// 34 | /// Default constructor 35 | /// 36 | public ModelCurveCreationInfo() 37 | { 38 | Points = new List(); 39 | Parameters = new Dictionary(); 40 | } 41 | 42 | /// 43 | /// Curve type (Line, Arc, Circle, Ellipse, Spline) 44 | /// 45 | [JsonProperty("curveType")] 46 | public string CurveType { get; set; } = "Line"; 47 | 48 | /// 49 | /// Points defining the curve geometry 50 | /// 51 | [JsonProperty("points")] 52 | public List Points { get; set; } 53 | 54 | /// 55 | /// Center point for circle, arc, ellipse 56 | /// 57 | [JsonProperty("center")] 58 | public Point Center { get; set; } 59 | 60 | /// 61 | /// Radius for circle or arc in millimeters 62 | /// 63 | [JsonProperty("radius")] 64 | public double? Radius { get; set; } 65 | 66 | /// 67 | /// X radius for ellipse in millimeters 68 | /// 69 | [JsonProperty("radiusX")] 70 | public double? RadiusX { get; set; } 71 | 72 | /// 73 | /// Y radius for ellipse in millimeters 74 | /// 75 | [JsonProperty("radiusY")] 76 | public double? RadiusY { get; set; } 77 | 78 | /// 79 | /// Rotation angle for ellipse in degrees 80 | /// 81 | [JsonProperty("rotation")] 82 | public double? Rotation { get; set; } 83 | 84 | /// 85 | /// Start angle for arc in degrees 86 | /// 87 | [JsonProperty("startAngle")] 88 | public double? StartAngle { get; set; } 89 | 90 | /// 91 | /// End angle for arc in degrees 92 | /// 93 | [JsonProperty("endAngle")] 94 | public double? EndAngle { get; set; } 95 | 96 | /// 97 | /// Normal vector for curve plane 98 | /// 99 | [JsonProperty("normal")] 100 | public Point Normal { get; set; } 101 | 102 | /// 103 | /// Sketch plane ID for curve 104 | /// 105 | [JsonProperty("sketchPlaneId")] 106 | public int SketchPlaneId { get; set; } 107 | 108 | /// 109 | /// Line style name 110 | /// 111 | [JsonProperty("lineStyle")] 112 | public string LineStyle { get; set; } 113 | 114 | /// 115 | /// Additional parameters 116 | /// 117 | [JsonProperty("parameters")] 118 | public Dictionary Parameters { get; set; } 119 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/OpeningCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Type of opening 31 | /// 32 | public enum OpeningType 33 | { 34 | WallOpening, 35 | FloorOpening, 36 | RoofOpening, 37 | ShaftOpening 38 | } 39 | 40 | /// 41 | /// Shape of opening 42 | /// 43 | public enum OpeningShape 44 | { 45 | Rectangular, 46 | Circular, 47 | Custom 48 | } 49 | 50 | /// 51 | /// Information about opening creation parameters 52 | /// 53 | public class OpeningCreationInfo 54 | { 55 | /// 56 | /// Default constructor 57 | /// 58 | public OpeningCreationInfo() 59 | { 60 | BoundaryPoints = new List(); 61 | Options = new Dictionary(); 62 | } 63 | 64 | /// 65 | /// Constructor with basic parameters 66 | /// 67 | /// Type of opening 68 | /// Location point for the opening 69 | /// Width of the opening (mm) 70 | /// Height of the opening (mm) 71 | public OpeningCreationInfo(OpeningType openingType, JZPoint location, double width, double height) 72 | { 73 | OpeningType = openingType; 74 | Location = location; 75 | Width = width; 76 | Height = height; 77 | BoundaryPoints = new List(); 78 | Options = new Dictionary(); 79 | } 80 | 81 | /// 82 | /// Type of opening 83 | /// 84 | [JsonProperty("openingType")] 85 | public OpeningType OpeningType { get; set; } = OpeningType.WallOpening; 86 | 87 | /// 88 | /// Shape of opening 89 | /// 90 | [JsonProperty("shape")] 91 | public OpeningShape Shape { get; set; } = OpeningShape.Rectangular; 92 | 93 | /// 94 | /// Location point for the opening 95 | /// 96 | [JsonProperty("location")] 97 | public JZPoint Location { get; set; } 98 | 99 | /// 100 | /// Direction vector for the opening (for rectangular openings) 101 | /// 102 | [JsonProperty("direction")] 103 | public JZPoint Direction { get; set; } 104 | 105 | /// 106 | /// Boundary points for custom shapes 107 | /// 108 | [JsonProperty("boundaryPoints")] 109 | public List BoundaryPoints { get; set; } 110 | 111 | /// 112 | /// Host element ID 113 | /// 114 | [JsonProperty("hostElementId")] 115 | public int HostElementId { get; set; } 116 | 117 | /// 118 | /// Width of the opening (mm) 119 | /// 120 | [JsonProperty("width")] 121 | public double Width { get; set; } 122 | 123 | /// 124 | /// Height of the opening (mm) 125 | /// 126 | [JsonProperty("height")] 127 | public double Height { get; set; } 128 | 129 | /// 130 | /// Length of the opening (mm) - for rectangular floor/roof openings 131 | /// 132 | [JsonProperty("length")] 133 | public double Length { get; set; } 134 | 135 | /// 136 | /// Sill height for wall openings (mm) 137 | /// 138 | [JsonProperty("sillHeight")] 139 | public double SillHeight { get; set; } 140 | 141 | /// 142 | /// Additional options 143 | /// 144 | [JsonProperty("options")] 145 | public Dictionary Options { get; set; } 146 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/RailingCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about railing creation parameters 31 | /// 32 | public class RailingCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public RailingCreationInfo() 38 | { 39 | PathPoints = new List(); 40 | Options = new Dictionary(); 41 | } 42 | 43 | /// 44 | /// Constructor with basic parameters 45 | /// 46 | /// Base level elevation (mm) 47 | /// Railing height (mm) 48 | /// Path points for the railing 49 | public RailingCreationInfo(double level, double height, List pathPoints) 50 | { 51 | Level = level; 52 | Height = height; 53 | PathPoints = pathPoints ?? new List(); 54 | Options = new Dictionary(); 55 | } 56 | 57 | /// 58 | /// Start point of the railing 59 | /// 60 | [JsonProperty("startPoint")] 61 | public JZPoint StartPoint { get; set; } 62 | 63 | /// 64 | /// End point of the railing 65 | /// 66 | [JsonProperty("endPoint")] 67 | public JZPoint EndPoint { get; set; } 68 | 69 | /// 70 | /// Path points defining the railing path 71 | /// 72 | [JsonProperty("pathPoints")] 73 | public List PathPoints { get; set; } 74 | 75 | /// 76 | /// Base level elevation (mm) 77 | /// 78 | [JsonProperty("level")] 79 | public double Level { get; set; } 80 | 81 | /// 82 | /// Level offset (mm) 83 | /// 84 | [JsonProperty("levelOffset")] 85 | public double LevelOffset { get; set; } 86 | 87 | /// 88 | /// Railing height (mm) 89 | /// 90 | [JsonProperty("height")] 91 | public double Height { get; set; } = 1070; 92 | 93 | /// 94 | /// Host element ID for the railing (if attaching to a stair, ramp, etc.) 95 | /// 96 | [JsonProperty("hostElementId")] 97 | public int HostElementId { get; set; } = -1; 98 | 99 | /// 100 | /// Is this a closed loop railing 101 | /// 102 | [JsonProperty("isClosedLoop")] 103 | public bool IsClosedLoop { get; set; } 104 | 105 | /// 106 | /// Railing type ID in Revit 107 | /// 108 | [JsonProperty("typeId")] 109 | public int TypeId { get; set; } = -1; 110 | 111 | /// 112 | /// Railing type name 113 | /// 114 | [JsonProperty("railingType")] 115 | public string RailingType { get; set; } = "Standard"; 116 | 117 | /// 118 | /// Railing material 119 | /// 120 | [JsonProperty("material")] 121 | public string Material { get; set; } = "Metal"; 122 | 123 | /// 124 | /// Additional options 125 | /// 126 | [JsonProperty("options")] 127 | public Dictionary Options { get; set; } 128 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/RampCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about ramp creation parameters 31 | /// 32 | public class RampCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public RampCreationInfo() 38 | { 39 | PathPoints = new List(); 40 | BoundaryPoints = new List(); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with basic parameters 46 | /// 47 | /// Base level elevation (mm) 48 | /// Top level elevation (mm) 49 | /// Ramp width (mm) 50 | /// Path points for the ramp 51 | public RampCreationInfo(double baseLevel, double topLevel, double width, List pathPoints) 52 | { 53 | BaseLevel = baseLevel; 54 | TopLevel = topLevel; 55 | Width = width; 56 | PathPoints = pathPoints ?? new List(); 57 | BoundaryPoints = new List(); 58 | Options = new Dictionary(); 59 | } 60 | 61 | /// 62 | /// Start point of the ramp 63 | /// 64 | [JsonProperty("startPoint")] 65 | public JZPoint StartPoint { get; set; } 66 | 67 | /// 68 | /// End point of the ramp 69 | /// 70 | [JsonProperty("endPoint")] 71 | public JZPoint EndPoint { get; set; } 72 | 73 | /// 74 | /// Path points defining the ramp path 75 | /// 76 | [JsonProperty("pathPoints")] 77 | public List PathPoints { get; set; } 78 | 79 | /// 80 | /// Boundary points defining the ramp outline (for custom ramps) 81 | /// 82 | [JsonProperty("boundaryPoints")] 83 | public List BoundaryPoints { get; set; } 84 | 85 | /// 86 | /// Base level elevation (mm) 87 | /// 88 | [JsonProperty("baseLevel")] 89 | public double BaseLevel { get; set; } 90 | 91 | /// 92 | /// Top level elevation (mm) 93 | /// 94 | [JsonProperty("topLevel")] 95 | public double TopLevel { get; set; } 96 | 97 | /// 98 | /// Base offset (mm) 99 | /// 100 | [JsonProperty("baseOffset")] 101 | public double BaseOffset { get; set; } 102 | 103 | /// 104 | /// Top offset (mm) 105 | /// 106 | [JsonProperty("topOffset")] 107 | public double TopOffset { get; set; } 108 | 109 | /// 110 | /// Ramp width (mm) 111 | /// 112 | [JsonProperty("width")] 113 | public double Width { get; set; } 114 | 115 | /// 116 | /// Ramp slope (percent) 117 | /// 118 | [JsonProperty("slope")] 119 | public double Slope { get; set; } 120 | 121 | /// 122 | /// Ramp type ID in Revit 123 | /// 124 | [JsonProperty("typeId")] 125 | public int TypeId { get; set; } 126 | 127 | /// 128 | /// Ramp type name 129 | /// 130 | [JsonProperty("rampType")] 131 | public string RampType { get; set; } 132 | 133 | /// 134 | /// Ramp material 135 | /// 136 | [JsonProperty("material")] 137 | public string Material { get; set; } 138 | 139 | /// 140 | /// Is this a custom ramp (using form instead of built-in ramp) 141 | /// 142 | [JsonProperty("isCustomRamp")] 143 | public bool IsCustomRamp { get; set; } 144 | 145 | /// 146 | /// Additional options 147 | /// 148 | [JsonProperty("options")] 149 | public Dictionary Options { get; set; } 150 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/ReferencePlaneCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Architecture; 27 | 28 | /// 29 | /// Information for reference plane creation 30 | /// 31 | public class ReferencePlaneCreationInfo 32 | { 33 | /// 34 | /// Default constructor 35 | /// 36 | public ReferencePlaneCreationInfo() 37 | { 38 | Points = new List(); 39 | Parameters = new Dictionary(); 40 | } 41 | 42 | /// 43 | /// Creation method (ByLine, ByNormal, ByPoints) 44 | /// 45 | [JsonProperty("creationMethod")] 46 | public string CreationMethod { get; set; } = "ByLine"; 47 | 48 | /// 49 | /// Name for the reference plane 50 | /// 51 | [JsonProperty("name")] 52 | public string Name { get; set; } = string.Empty; 53 | 54 | /// 55 | /// Bubble end point for line-based creation (millimeters) 56 | /// 57 | [JsonProperty("bubbleEnd")] 58 | public Point BubbleEnd { get; set; } 59 | 60 | /// 61 | /// Free end point for line-based creation (millimeters) 62 | /// 63 | [JsonProperty("freeEnd")] 64 | public Point FreeEnd { get; set; } 65 | 66 | /// 67 | /// Third point for defining the plane (millimeters) 68 | /// 69 | [JsonProperty("thirdPoint")] 70 | public Point ThirdPoint { get; set; } 71 | 72 | /// 73 | /// Origin point for normal-based creation (millimeters) 74 | /// 75 | [JsonProperty("origin")] 76 | public Point Origin { get; set; } 77 | 78 | /// 79 | /// Normal vector for normal-based creation 80 | /// 81 | [JsonProperty("normal")] 82 | public Point Normal { get; set; } 83 | 84 | /// 85 | /// Length of the reference plane line in millimeters 86 | /// 87 | [JsonProperty("length")] 88 | public double Length { get; set; } 89 | 90 | /// 91 | /// Points for creating reference plane (for ByPoints method) 92 | /// 93 | [JsonProperty("points")] 94 | public List Points { get; set; } 95 | 96 | /// 97 | /// Additional parameters 98 | /// 99 | [JsonProperty("parameters")] 100 | public Dictionary Parameters { get; set; } 101 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/RoofInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Architecture; 27 | 28 | /// 29 | /// Information about the building roof 30 | /// 31 | public class RoofInfo 32 | { 33 | /// 34 | /// Default constructor 35 | /// 36 | public RoofInfo() 37 | { 38 | Options = new Dictionary(); 39 | } 40 | 41 | /// 42 | /// Constructor with basic parameters 43 | /// 44 | /// Roof type 45 | /// Roof elevation (mm) 46 | /// Roof thickness (mm) 47 | /// Roof material 48 | public RoofInfo(string type, double level, double thickness, string material = "Concrete") 49 | { 50 | Type = type; 51 | Level = level; 52 | Thickness = thickness; 53 | Material = material; 54 | 55 | Options = new Dictionary(); 56 | } 57 | 58 | /// 59 | /// Roof type 60 | /// 61 | [JsonProperty("type")] 62 | public string Type { get; set; } // Flat, Gable, Hip, etc. 63 | 64 | /// 65 | /// Roof elevation (mm) 66 | /// 67 | [JsonProperty("level")] 68 | public double Level { get; set; } 69 | 70 | /// 71 | /// Roof height (for pitched roofs) (mm) 72 | /// 73 | [JsonProperty("height")] 74 | public double Height { get; set; } 75 | 76 | /// 77 | /// Roof thickness (mm) 78 | /// 79 | [JsonProperty("thickness")] 80 | public double Thickness { get; set; } 81 | 82 | /// 83 | /// Roof slope (degrees) 84 | /// 85 | [JsonProperty("slope")] 86 | public double Slope { get; set; } 87 | 88 | /// 89 | /// Roof overhang from walls (mm) 90 | /// 91 | [JsonProperty("overhang")] 92 | public double Overhang { get; set; } 93 | 94 | /// 95 | /// Roof material 96 | /// 97 | [JsonProperty("material")] 98 | public string Material { get; set; } 99 | 100 | /// 101 | /// Additional options 102 | /// 103 | [JsonProperty("options")] 104 | public Dictionary Options { get; set; } = new(); 105 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/RoomCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about room creation parameters 31 | /// 32 | public class RoomCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public RoomCreationInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | Options = new Dictionary(); 41 | } 42 | 43 | /// 44 | /// Room location point (mm) 45 | /// 46 | [JsonProperty("location")] 47 | public JZPoint Location { get; set; } 48 | 49 | /// 50 | /// Room name 51 | /// 52 | [JsonProperty("name")] 53 | public string Name { get; set; } = "Room"; 54 | 55 | /// 56 | /// Room number 57 | /// 58 | [JsonProperty("number")] 59 | public string Number { get; set; } 60 | 61 | /// 62 | /// Level elevation (mm) 63 | /// 64 | [JsonProperty("level")] 65 | public double Level { get; set; } 66 | 67 | /// 68 | /// Level ID in Revit 69 | /// 70 | [JsonProperty("levelId")] 71 | public int LevelId { get; set; } 72 | 73 | /// 74 | /// Room height (mm) 75 | /// 76 | [JsonProperty("height")] 77 | public double Height { get; set; } 78 | 79 | /// 80 | /// Room phase ID 81 | /// 82 | [JsonProperty("phaseId")] 83 | public int PhaseId { get; set; } 84 | 85 | /// 86 | /// Additional options 87 | /// 88 | [JsonProperty("options")] 89 | public Dictionary Options { get; set; } 90 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/ShaftCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Shape of shaft 31 | /// 32 | public enum ShaftShape 33 | { 34 | Rectangular, 35 | Circular, 36 | Custom 37 | } 38 | 39 | /// 40 | /// Information about shaft creation parameters 41 | /// 42 | public class ShaftCreationInfo 43 | { 44 | /// 45 | /// Default constructor 46 | /// 47 | public ShaftCreationInfo() 48 | { 49 | BoundaryPoints = new List(); 50 | Options = new Dictionary(); 51 | } 52 | 53 | /// 54 | /// Constructor with basic parameters 55 | /// 56 | /// Location point for the shaft 57 | /// Width of the shaft (mm) 58 | /// Length of the shaft (mm) 59 | /// Base level elevation (mm) 60 | /// Top level elevation (mm) 61 | public ShaftCreationInfo(JZPoint location, double width, double length, double baseLevel, double topLevel) 62 | { 63 | Location = location; 64 | Width = width; 65 | Length = length; 66 | BaseLevel = baseLevel; 67 | TopLevel = topLevel; 68 | BoundaryPoints = new List(); 69 | Options = new Dictionary(); 70 | } 71 | 72 | /// 73 | /// Shape of shaft 74 | /// 75 | [JsonProperty("shape")] 76 | public ShaftShape Shape { get; set; } = ShaftShape.Rectangular; 77 | 78 | /// 79 | /// Location point for the shaft 80 | /// 81 | [JsonProperty("location")] 82 | public JZPoint Location { get; set; } 83 | 84 | /// 85 | /// Direction vector for the shaft (for rectangular shafts) 86 | /// 87 | [JsonProperty("direction")] 88 | public JZPoint Direction { get; set; } 89 | 90 | /// 91 | /// Boundary points for custom shapes 92 | /// 93 | [JsonProperty("boundaryPoints")] 94 | public List BoundaryPoints { get; set; } 95 | 96 | /// 97 | /// Base level elevation (mm) 98 | /// 99 | [JsonProperty("baseLevel")] 100 | public double BaseLevel { get; set; } 101 | 102 | /// 103 | /// Top level elevation (mm) 104 | /// 105 | [JsonProperty("topLevel")] 106 | public double TopLevel { get; set; } 107 | 108 | /// 109 | /// Width of the shaft (mm) 110 | /// 111 | [JsonProperty("width")] 112 | public double Width { get; set; } 113 | 114 | /// 115 | /// Length of the shaft (mm) - for rectangular shafts 116 | /// 117 | [JsonProperty("length")] 118 | public double Length { get; set; } 119 | 120 | /// 121 | /// Shaft name 122 | /// 123 | [JsonProperty("name")] 124 | public string Name { get; set; } = "Shaft"; 125 | 126 | /// 127 | /// Shaft type (Elevator, Mechanical, etc.) 128 | /// 129 | [JsonProperty("shaftType")] 130 | public string ShaftType { get; set; } = "Elevator"; 131 | 132 | /// 133 | /// Additional options 134 | /// 135 | [JsonProperty("options")] 136 | public Dictionary Options { get; set; } 137 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/WallCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about wall creation parameters 31 | /// 32 | public class WallCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public WallCreationInfo() 38 | { 39 | StartPoint = new JZPoint(0, 0, 0); 40 | EndPoint = new JZPoint(0, 0, 0); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with position and dimensions 46 | /// 47 | /// Start X position (mm) 48 | /// Start Y position (mm) 49 | /// Start Z position (mm) 50 | /// End X position (mm) 51 | /// End Y position (mm) 52 | /// End Z position (mm) 53 | /// Wall height (mm) 54 | /// Wall thickness (mm) 55 | /// Base level elevation (mm) 56 | public WallCreationInfo(double startX, double startY, double startZ, double endX, double endY, double endZ, 57 | double height, double thickness, double level = 0) 58 | { 59 | StartPoint = new JZPoint(startX, startY, startZ); 60 | EndPoint = new JZPoint(endX, endY, endZ); 61 | Height = height; 62 | Thickness = thickness; 63 | BaseLevel = level; 64 | } 65 | 66 | /// 67 | /// Wall start position (mm) 68 | /// 69 | [JsonProperty("startPoint")] 70 | public JZPoint StartPoint { get; set; } 71 | 72 | /// 73 | /// Wall end position (mm) 74 | /// 75 | [JsonProperty("endPoint")] 76 | public JZPoint EndPoint { get; set; } 77 | 78 | /// 79 | /// Wall height (mm) 80 | /// 81 | [JsonProperty("height")] 82 | public double Height { get; set; } 83 | 84 | /// 85 | /// Wall thickness (mm) 86 | /// 87 | [JsonProperty("thickness")] 88 | public double Thickness { get; set; } 89 | 90 | /// 91 | /// Base level elevation (mm) 92 | /// 93 | [JsonProperty("baseLevel")] 94 | public double BaseLevel { get; set; } 95 | 96 | /// 97 | /// Base offset (mm) 98 | /// 99 | [JsonProperty("baseOffset")] 100 | public double BaseOffset { get; set; } 101 | 102 | /// 103 | /// Top constraint type (0=Unconstrained, 1=Up to level, 2=Unconnected height) 104 | /// 105 | [JsonProperty("topConstraintType")] 106 | public int TopConstraintType { get; set; } 107 | 108 | /// 109 | /// Top level ID (only used if TopConstraintType = 1) 110 | /// 111 | [JsonProperty("topLevelId")] 112 | public int TopLevelId { get; set; } 113 | 114 | /// 115 | /// Top offset (mm) (used if TopConstraintType = 1) 116 | /// 117 | [JsonProperty("topOffset")] 118 | public double TopOffset { get; set; } 119 | 120 | /// 121 | /// Wall type 122 | /// 123 | [JsonProperty("wallType")] 124 | public string WallType { get; set; } = "Basic Wall"; // Basic Wall, Curtain Wall, etc. 125 | 126 | /// 127 | /// Wall type ID in Revit 128 | /// 129 | [JsonProperty("typeId")] 130 | public int TypeId { get; set; } 131 | 132 | /// 133 | /// Wall material 134 | /// 135 | [JsonProperty("material")] 136 | public string Material { get; set; } = "Concrete"; 137 | 138 | /// 139 | /// Is structural 140 | /// 141 | [JsonProperty("isStructural")] 142 | public bool IsStructural { get; set; } = true; 143 | 144 | /// 145 | /// Flip wall direction 146 | /// 147 | [JsonProperty("flipped")] 148 | public bool Flipped { get; set; } 149 | 150 | /// 151 | /// Additional options 152 | /// 153 | [JsonProperty("options")] 154 | public Dictionary Options { get; set; } 155 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/WindowInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about a window 31 | /// 32 | public class WindowInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public WindowInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | } 41 | 42 | /// 43 | /// Constructor with position and dimensions 44 | /// 45 | /// X position (mm) 46 | /// Y position (mm) 47 | /// Z position (mm) 48 | /// Width (mm) 49 | /// Height (mm) 50 | /// Height from floor (mm) 51 | /// Floor elevation (mm) 52 | public WindowInfo(double x, double y, double z, double width, double height, double sillHeight, 53 | double level) 54 | { 55 | Location = new JZPoint(x, y, z); 56 | Width = width; 57 | Height = height; 58 | SillHeight = sillHeight; 59 | Level = level; 60 | } 61 | 62 | /// 63 | /// Window position (mm) 64 | /// 65 | [JsonProperty("location")] 66 | public JZPoint Location { get; set; } 67 | 68 | /// 69 | /// Host wall for the window (reference ID) 70 | /// 71 | [JsonProperty("hostWallId")] 72 | public string HostWallId { get; set; } 73 | 74 | /// 75 | /// Window width (mm) 76 | /// 77 | [JsonProperty("width")] 78 | public double Width { get; set; } 79 | 80 | /// 81 | /// Window height (mm) 82 | /// 83 | [JsonProperty("height")] 84 | public double Height { get; set; } 85 | 86 | /// 87 | /// Height from floor (mm) 88 | /// 89 | [JsonProperty("sillHeight")] 90 | public double SillHeight { get; set; } 91 | 92 | /// 93 | /// Host floor elevation (mm) 94 | /// 95 | [JsonProperty("level")] 96 | public double Level { get; set; } 97 | 98 | /// 99 | /// Window type 100 | /// 101 | [JsonProperty("type")] 102 | public string Type { get; set; } // Fixed, Casement, Sliding, etc. 103 | 104 | /// 105 | /// Window type ID in Revit 106 | /// 107 | [JsonProperty("typeId")] 108 | public int TypeId { get; set; } = -1; 109 | 110 | /// 111 | /// Window frame material 112 | /// 113 | [JsonProperty("frameMaterial")] 114 | public string FrameMaterial { get; set; } 115 | 116 | /// 117 | /// Glass material 118 | /// 119 | [JsonProperty("glassMaterial")] 120 | public string GlassMaterial { get; set; } 121 | 122 | /// 123 | /// Additional options 124 | /// 125 | [JsonProperty("options")] 126 | public Dictionary Options { get; set; } = new(); 127 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Architecture/ZoneCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.Architecture; 28 | 29 | /// 30 | /// Information about zone creation parameters 31 | /// 32 | public class ZoneCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public ZoneCreationInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | RoomIds = new List(); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Zone name 46 | /// 47 | [JsonProperty("name")] 48 | public string Name { get; set; } = "Zone"; 49 | 50 | /// 51 | /// Zone location point (mm) 52 | /// 53 | [JsonProperty("location")] 54 | public JZPoint Location { get; set; } 55 | 56 | /// 57 | /// List of room IDs to add to this zone 58 | /// 59 | [JsonProperty("roomIds")] 60 | public List RoomIds { get; set; } 61 | 62 | /// 63 | /// Zone color (RGB hex code) 64 | /// 65 | [JsonProperty("color")] 66 | public string Color { get; set; } = "#CCCCCC"; 67 | 68 | /// 69 | /// Additional options 70 | /// 71 | [JsonProperty("options")] 72 | public Dictionary Options { get; set; } 73 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/AIResult.cs: -------------------------------------------------------------------------------- 1 | namespace RevitMCPCommandSet.Models.Common; 2 | 3 | public class AIResult 4 | { 5 | /// 6 | /// 是否成功 7 | /// 8 | public bool Success { get; set; } 9 | 10 | /// 11 | /// 消息 12 | /// 13 | public string Message { get; set; } 14 | 15 | /// 16 | /// 返回数据 17 | /// 18 | public T Response { get; set; } 19 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/ElementInfo.cs: -------------------------------------------------------------------------------- 1 | namespace RevitMCPCommandSet.Models.Common 2 | { 3 | public class ElementInfo 4 | { 5 | public long Id { get; set; } 6 | public string UniqueId { get; set; } 7 | public string Name { get; set; } 8 | public string Category { get; set; } 9 | public Dictionary Properties { get; set; } = new Dictionary(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/FamilyTypeInfo.cs: -------------------------------------------------------------------------------- 1 | namespace RevitMCPCommandSet.Models.Common 2 | { 3 | public class FamilyTypeInfo 4 | { 5 | public long FamilyTypeId { get; set; } 6 | public string UniqueId { get; set; } 7 | public string FamilyName { get; set; } 8 | public string TypeName { get; set; } 9 | public string Category { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/FilterSetting.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace RevitMCPCommandSet.Models.Common 9 | { 10 | /// 11 | /// 过滤器设置 - 支持组合条件过滤 12 | /// 13 | public class FilterSetting 14 | { 15 | /// 16 | /// 获取或设置要过滤的 Revit 内置类别名称(如"OST_Walls")。 17 | /// 如果为 null 或空,则不进行类别过滤。 18 | /// 19 | [JsonProperty("filterCategory")] 20 | public string FilterCategory { get; set; } = null; 21 | /// 22 | /// 获取或设置要过滤的 Revit 元素类型名称(如"Wall"或"Autodesk.Revit.DB.Wall")。 23 | /// 如果为 null 或空,则不进行类型过滤。 24 | /// 25 | [JsonProperty("filterElementType")] 26 | public string FilterElementType { get; set; } = null; 27 | /// 28 | /// 获取或设置要过滤的族类型的ElementId值(FamilySymbol)。 29 | /// 如果为0或负数,则不进行族过滤。 30 | /// 注意:此过滤器仅适用于元素实例,不适用于类型元素。 31 | /// 32 | [JsonProperty("filterFamilySymbolId")] 33 | public int FilterFamilySymbolId { get; set; } = -1; 34 | /// 35 | /// 获取或设置是否包含元素类型(如墙类型、门类型等) 36 | /// 37 | [JsonProperty("includeTypes")] 38 | public bool IncludeTypes { get; set; } = false; 39 | /// 40 | /// 获取或设置是否包含元素实例(如已放置的墙、门等) 41 | /// 42 | [JsonProperty("includeInstances")] 43 | public bool IncludeInstances { get; set; } = true; 44 | /// 45 | /// 获取或设置是否仅返回在当前视图中可见的元素。 46 | /// 注意:此过滤器仅适用于元素实例,不适用于类型元素。 47 | /// 48 | [JsonProperty("filterVisibleInCurrentView")] 49 | public bool FilterVisibleInCurrentView { get; set; } 50 | /// 51 | /// 获取或设置空间范围过滤的最小点坐标 (单位:mm) 52 | /// 如果设置了此值和BoundingBoxMax,将筛选出与此边界框相交的元素 53 | /// 54 | [JsonProperty("boundingBoxMin")] 55 | public JZPoint BoundingBoxMin { get; set; } = null; 56 | /// 57 | /// 获取或设置空间范围过滤的最大点坐标 (单位:mm) 58 | /// 如果设置了此值和BoundingBoxMin,将筛选出与此边界框相交的元素 59 | /// 60 | [JsonProperty("boundingBoxMax")] 61 | public JZPoint BoundingBoxMax { get; set; } = null; 62 | /// 63 | /// 最大元素数量限制 64 | /// 65 | [JsonProperty("maxElements")] 66 | public int MaxElements { get; set; } = 50; 67 | /// 68 | /// 验证过滤器设置的有效性,检查潜在的冲突 69 | /// 70 | /// 如果设置有效返回true,否则返回false 71 | public bool Validate(out string errorMessage) 72 | { 73 | errorMessage = null; 74 | 75 | // 检查是否至少选择了一种元素种类 76 | if (!IncludeTypes && !IncludeInstances) 77 | { 78 | errorMessage = "过滤设置无效: 必须至少包含元素类型或元素实例之一"; 79 | return false; 80 | } 81 | 82 | // 检查是否至少指定了一个过滤条件 83 | if (string.IsNullOrWhiteSpace(FilterCategory) && 84 | string.IsNullOrWhiteSpace(FilterElementType) && 85 | FilterFamilySymbolId <= 0) 86 | { 87 | errorMessage = "过滤设置无效: 必须至少指定一个过滤条件(类别、元素类型或族类型)"; 88 | return false; 89 | } 90 | 91 | // 检查类型元素与某些过滤器的冲突 92 | if (IncludeTypes && !IncludeInstances) 93 | { 94 | List invalidFilters = new List(); 95 | if (FilterFamilySymbolId > 0) 96 | invalidFilters.Add("族实例过滤"); 97 | if (FilterVisibleInCurrentView) 98 | invalidFilters.Add("视图可见性过滤"); 99 | if (invalidFilters.Count > 0) 100 | { 101 | errorMessage = $"当仅过滤类型元素时,以下过滤器不适用: {string.Join(", ", invalidFilters)}"; 102 | return false; 103 | } 104 | } 105 | // 检查空间范围过滤器的有效性 106 | if (BoundingBoxMin != null && BoundingBoxMax != null) 107 | { 108 | // 确保最小点小于或等于最大点 109 | if (BoundingBoxMin.X > BoundingBoxMax.X || 110 | BoundingBoxMin.Y > BoundingBoxMax.Y || 111 | BoundingBoxMin.Z > BoundingBoxMax.Z) 112 | { 113 | errorMessage = "空间范围过滤器设置无效: 最小点坐标必须小于或等于最大点坐标"; 114 | return false; 115 | } 116 | } 117 | else if (BoundingBoxMin != null || BoundingBoxMax != null) 118 | { 119 | errorMessage = "空间范围过滤器设置无效: 必须同时设置最小点和最大点坐标"; 120 | return false; 121 | } 122 | return true; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/JZFace.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitMCPCommandSet.Models.Common; 4 | 5 | /// 6 | /// 三维面 7 | /// 8 | public class JZFace 9 | { 10 | /// 11 | /// 构造函数 12 | /// 13 | public JZFace() 14 | { 15 | InnerLoops = new List>(); 16 | OuterLoop = new List(); 17 | } 18 | 19 | /// 20 | /// 外环(List> 类型) 21 | /// 22 | [JsonProperty("outerLoop")] 23 | public List OuterLoop { get; set; } 24 | 25 | /// 26 | /// 内环(List 类型,表示一个或多个内环) 27 | /// 28 | [JsonProperty("innerLoops")] 29 | public List> InnerLoops { get; set; } 30 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/JZLine.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitMCPCommandSet.Models.Common; 4 | 5 | /// 6 | /// 三维线段 7 | /// 8 | public class JZLine 9 | { 10 | /// 11 | /// 构造函数 12 | /// 13 | public JZLine() 14 | { 15 | } 16 | 17 | /// 18 | /// 构造函数 19 | /// 20 | public JZLine(JZPoint p0, JZPoint p1) 21 | { 22 | P0 = p0; 23 | P1 = p1; 24 | } 25 | 26 | /// 27 | /// 四个double作为参数的构造函数 28 | /// 29 | /// 起点X坐标 30 | /// 起点Y坐标 31 | /// 起点Z坐标 32 | /// 终点X坐标 33 | /// 终点Y坐标 34 | /// 终点Z坐标 35 | public JZLine(double x0, double y0, double z0, double x1, double y1, double z1) 36 | { 37 | P0 = new JZPoint(x0, y0, z0); 38 | P1 = new JZPoint(x1, y1, z1); 39 | } 40 | 41 | /// 42 | /// 四个double作为参数的构造函数 43 | /// 44 | /// 起点X坐标 45 | /// 起点Y坐标 46 | /// 起点Z坐标 47 | /// 终点X坐标 48 | /// 终点Y坐标 49 | /// 终点Z坐标 50 | public JZLine(double x0, double y0, double x1, double y1) 51 | { 52 | P0 = new JZPoint(x0, y0, 0); 53 | P1 = new JZPoint(x1, y1, 0); 54 | } 55 | 56 | /// 57 | /// 起点 58 | /// 59 | [JsonProperty("p0")] 60 | public JZPoint P0 { get; set; } 61 | 62 | /// 63 | /// 终点 64 | /// 65 | [JsonProperty("p1")] 66 | public JZPoint P1 { get; set; } 67 | 68 | /// 69 | /// 获取线段的长度 70 | /// 71 | public double GetLength() 72 | { 73 | if (P0 == null || P1 == null) 74 | throw new InvalidOperationException("JZLine must have both P0 and P1 defined to calculate length."); 75 | 76 | // 计算三维点之间的距离 77 | var dx = P1.X - P0.X; 78 | var dy = P1.Y - P0.Y; 79 | var dz = P1.Z - P0.Z; 80 | 81 | return Math.Sqrt(dx * dx + dy * dy + dz * dz); 82 | } 83 | 84 | /// 85 | /// 获取线段的方向 86 | /// 返回一个归一化的 JZPoint 表示方向向量 87 | /// 88 | public JZPoint GetDirection() 89 | { 90 | if (P0 == null || P1 == null) 91 | throw new InvalidOperationException("JZLine must have both P0 and P1 defined to calculate direction."); 92 | 93 | // 计算方向向量 94 | var dx = P1.X - P0.X; 95 | var dy = P1.Y - P0.Y; 96 | var dz = P1.Z - P0.Z; 97 | 98 | // 计算向量的模 99 | var length = Math.Sqrt(dx * dx + dy * dy + dz * dz); 100 | 101 | if (length == 0) 102 | throw new InvalidOperationException("Cannot determine direction for a line with zero length."); 103 | 104 | // 返回归一化向量 105 | return new JZPoint(dx / length, dy / length, dz / length); 106 | } 107 | 108 | /// 109 | /// 转换为Revit的Line 110 | /// 单位转换:mm -> ft 111 | /// 112 | public static Line ToLine(JZLine jzLine) 113 | { 114 | if (jzLine.P0 == null || jzLine.P1 == null) return null; 115 | 116 | return Line.CreateBound(JZPoint.ToXYZ(jzLine.P0), JZPoint.ToXYZ(jzLine.P1)); 117 | } 118 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/JZPoint.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitMCPCommandSet.Models.Common; 4 | 5 | /// 6 | /// 三维点 7 | /// 8 | public class JZPoint 9 | { 10 | /// 11 | /// 构造函数 12 | /// 13 | public JZPoint() 14 | { 15 | } 16 | 17 | /// 18 | /// 构造函数 19 | /// 20 | public JZPoint(double x, double y, double z) 21 | { 22 | X = x; 23 | Y = y; 24 | Z = z; 25 | } 26 | 27 | /// 28 | /// 构造函数 29 | /// 30 | public JZPoint(double x, double y) 31 | { 32 | X = x; 33 | Y = y; 34 | Z = 0; 35 | } 36 | 37 | [JsonProperty("x")] public double X { get; set; } 38 | 39 | [JsonProperty("y")] public double Y { get; set; } 40 | 41 | [JsonProperty("z")] public double Z { get; set; } 42 | 43 | /// 44 | /// 转换为Revit的XYZ点 45 | /// 单位转换:mm -> ft 46 | /// 47 | public static XYZ ToXYZ(JZPoint jzPoint) 48 | { 49 | return new XYZ(jzPoint.X / 304.8, jzPoint.Y / 304.8, jzPoint.Z / 304.8); 50 | } 51 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/LineElement.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitMCPCommandSet.Models.Common; 4 | 5 | /// 6 | /// 线状构件 7 | /// 8 | public class LineElement 9 | { 10 | public LineElement() 11 | { 12 | Parameters = new Dictionary(); 13 | } 14 | 15 | /// 16 | /// 构件类型 17 | /// 18 | [JsonProperty("category")] 19 | public string Category { get; set; } = "INVALID"; 20 | 21 | /// 22 | /// 类型Id 23 | /// 24 | [JsonProperty("typeId")] 25 | public int TypeId { get; set; } = -1; 26 | 27 | /// 28 | /// 路径曲线 29 | /// 30 | [JsonProperty("locationLine")] 31 | public JZLine LocationLine { get; set; } 32 | 33 | /// 34 | /// 厚度 35 | /// 36 | [JsonProperty("thickness")] 37 | public double Thickness { get; set; } 38 | 39 | /// 40 | /// 高度 41 | /// 42 | [JsonProperty("height")] 43 | public double Height { get; set; } 44 | 45 | /// 46 | /// 底部标高 47 | /// 48 | [JsonProperty("baseLevel")] 49 | public double BaseLevel { get; set; } 50 | 51 | /// 52 | /// 底部偏移/基于面的偏移 53 | /// 54 | [JsonProperty("baseOffset")] 55 | public double BaseOffset { get; set; } 56 | 57 | /// 58 | /// 参数化属性 59 | /// 60 | [JsonProperty("parameters")] 61 | public Dictionary Parameters { get; set; } 62 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/OperationSetting.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace RevitMCPCommandSet.Models.Common 9 | { 10 | /// 11 | /// 定义可对图元执行的操作类型 12 | /// 13 | public enum ElementOperationType 14 | { 15 | /// 16 | /// 选择图元 17 | /// 18 | Select, 19 | 20 | /// 21 | /// 选择框 22 | /// 23 | SelectionBox, 24 | 25 | /// 26 | /// 设置图元颜色和填充 27 | /// 28 | SetColor, 29 | 30 | /// 31 | /// 设置图元透明度 32 | /// 33 | SetTransparency, 34 | 35 | /// 36 | /// 删除图元 37 | /// 38 | Delete, 39 | 40 | /// 41 | /// 隐藏图元 42 | /// 43 | Hide, 44 | 45 | /// 46 | /// 临时隐藏图元 47 | /// 48 | TempHide, 49 | 50 | /// 51 | /// 隔离图元(单独显示) 52 | /// 53 | Isolate, 54 | 55 | /// 56 | /// 取消隐藏图元 57 | /// 58 | Unhide, 59 | 60 | /// 61 | /// 重置隔离(显示所有图元) 62 | /// 63 | ResetIsolate, 64 | } 65 | 66 | 67 | /// 68 | /// 操作元素的设置 69 | /// 70 | public class OperationSetting 71 | { 72 | /// 73 | /// 需要操作的元素ID列表 74 | /// 75 | [JsonProperty("elementIds")] 76 | public List ElementIds = new List(); 77 | 78 | /// 79 | /// 需要执行的动作,存储ElementOperationType枚举的string类型的值 80 | /// 81 | [JsonProperty("action")] 82 | public string Action { get; set; } = "Select"; 83 | 84 | /// 85 | /// 透明度值(0-100),数值越大透明度越高 86 | /// 87 | [JsonProperty("transparencyValue")] 88 | public int TransparencyValue { get; set; } = 50; 89 | 90 | /// 91 | /// 设置图元颜色(RGB格式),默认为红色 92 | /// 93 | [JsonProperty("colorValue")] 94 | public int[] ColorValue { get; set; } = new int[] { 255, 0, 0 }; // 默认红色 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/PointElement.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitMCPCommandSet.Models.Common; 4 | 5 | /// 6 | /// 点状构件 7 | /// 8 | public class PointElement 9 | { 10 | public PointElement() 11 | { 12 | Parameters = new Dictionary(); 13 | } 14 | 15 | /// 16 | /// 构件类型 17 | /// 18 | [JsonProperty("category")] 19 | public string Category { get; set; } = "INVALID"; 20 | 21 | /// 22 | /// 类型Id 23 | /// 24 | [JsonProperty("typeId")] 25 | public int TypeId { get; set; } = -1; 26 | 27 | /// 28 | /// 定位点坐标 29 | /// 30 | [JsonProperty("locationPoint")] 31 | public JZPoint LocationPoint { get; set; } 32 | 33 | /// 34 | /// 宽度 35 | /// 36 | [JsonProperty("width")] 37 | public double Width { get; set; } = -1; 38 | 39 | /// 40 | /// 深度 41 | /// 42 | [JsonProperty("depth")] 43 | public double Depth { get; set; } 44 | 45 | /// 46 | /// 高度 47 | /// 48 | [JsonProperty("height")] 49 | public double Height { get; set; } 50 | 51 | /// 52 | /// 底部标高 53 | /// 54 | [JsonProperty("baseLevel")] 55 | public double BaseLevel { get; set; } 56 | 57 | /// 58 | /// 底部偏移 59 | /// 60 | [JsonProperty("baseOffset")] 61 | public double BaseOffset { get; set; } 62 | 63 | /// 64 | /// 参数化属性 65 | /// 66 | [JsonProperty("parameters")] 67 | public Dictionary Parameters { get; set; } 68 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/SurfaceElement.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace RevitMCPCommandSet.Models.Common; 4 | 5 | /// 6 | /// 面状构件 7 | /// 8 | public class SurfaceElement 9 | { 10 | public SurfaceElement() 11 | { 12 | Parameters = new Dictionary(); 13 | } 14 | 15 | /// 16 | /// 构件类型 17 | /// 18 | [JsonProperty("category")] 19 | public string Category { get; set; } = "INVALID"; 20 | 21 | /// 22 | /// 类型Id 23 | /// 24 | [JsonProperty("typeId")] 25 | public int TypeId { get; set; } = -1; 26 | 27 | /// 28 | /// 壳形轮廓边界 29 | /// 30 | [JsonProperty("boundary")] 31 | public JZFace Boundary { get; set; } 32 | 33 | /// 34 | /// 厚度 35 | /// 36 | [JsonProperty("thickness")] 37 | public double Thickness { get; set; } 38 | 39 | /// 40 | /// 底部标高 41 | /// 42 | [JsonProperty("baseLevel")] 43 | public double BaseLevel { get; set; } 44 | 45 | /// 46 | /// 底部偏移 47 | /// 48 | [JsonProperty("baseOffset")] 49 | public double BaseOffset { get; set; } 50 | 51 | /// 52 | /// 参数化属性 53 | /// 54 | public Dictionary Parameters { get; set; } 55 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/ViewElementsResult.cs: -------------------------------------------------------------------------------- 1 | namespace RevitMCPCommandSet.Models.Common 2 | { 3 | public class ViewElementsResult 4 | { 5 | public long ViewId { get; set; } 6 | public string ViewName { get; set; } 7 | public int TotalElementsInView { get; set; } 8 | public int FilteredElementCount { get; set; } 9 | public List Elements { get; set; } = new List(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Common/ViewInfo.cs: -------------------------------------------------------------------------------- 1 | namespace RevitMCPCommandSet.Models.Common 2 | { 3 | public class ViewInfo 4 | { 5 | public long Id { get; set; } 6 | public string UniqueId { get; set; } 7 | public string Name { get; set; } 8 | public string ViewType { get; set; } 9 | public bool IsTemplate { get; set; } 10 | public int Scale { get; set; } 11 | public string DetailLevel { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/MEP/ConduitCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.MEP; 28 | 29 | /// 30 | /// Information about conduit creation parameters 31 | /// 32 | public class ConduitCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public ConduitCreationInfo() 38 | { 39 | StartPoint = new JZPoint(0, 0, 0); 40 | EndPoint = new JZPoint(0, 0, 0); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with position and dimensions 46 | /// 47 | /// Start X position (mm) 48 | /// Start Y position (mm) 49 | /// Start Z position (mm) 50 | /// End X position (mm) 51 | /// End Y position (mm) 52 | /// End Z position (mm) 53 | /// Conduit diameter (mm) 54 | /// Base level elevation (mm) 55 | public ConduitCreationInfo(double startX, double startY, double startZ, double endX, double endY, double endZ, 56 | double diameter, double level = 0) 57 | { 58 | StartPoint = new JZPoint(startX, startY, startZ); 59 | EndPoint = new JZPoint(endX, endY, endZ); 60 | Diameter = diameter; 61 | BaseLevel = level; 62 | } 63 | 64 | /// 65 | /// Conduit start position (mm) 66 | /// 67 | [JsonProperty("startPoint")] 68 | public JZPoint StartPoint { get; set; } 69 | 70 | /// 71 | /// Conduit end position (mm) 72 | /// 73 | [JsonProperty("endPoint")] 74 | public JZPoint EndPoint { get; set; } 75 | 76 | /// 77 | /// Conduit diameter (mm) 78 | /// 79 | [JsonProperty("diameter")] 80 | public double Diameter { get; set; } 81 | 82 | /// 83 | /// Base level elevation (mm) 84 | /// 85 | [JsonProperty("baseLevel")] 86 | public double BaseLevel { get; set; } 87 | 88 | /// 89 | /// Base offset (mm) 90 | /// 91 | [JsonProperty("baseOffset")] 92 | public double BaseOffset { get; set; } 93 | 94 | /// 95 | /// Conduit system type 96 | /// 97 | [JsonProperty("systemType")] 98 | public string SystemType { get; set; } // Power, Data, Communication, etc. 99 | 100 | /// 101 | /// Conduit type 102 | /// 103 | [JsonProperty("conduitType")] 104 | public string ConduitType { get; set; } // Standard, EMT, IMC, RMC, etc. 105 | 106 | /// 107 | /// Conduit type ID in Revit 108 | /// 109 | [JsonProperty("typeId")] 110 | public int TypeId { get; set; } 111 | 112 | /// 113 | /// Conduit material 114 | /// 115 | [JsonProperty("material")] 116 | public string Material { get; set; } = "Steel"; 117 | 118 | /// 119 | /// Additional options 120 | /// 121 | [JsonProperty("options")] 122 | public Dictionary Options { get; set; } 123 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/MEP/DuctCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.MEP; 28 | 29 | /// 30 | /// Information about duct creation parameters 31 | /// 32 | public class DuctCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public DuctCreationInfo() 38 | { 39 | StartPoint = new JZPoint(0, 0, 0); 40 | EndPoint = new JZPoint(0, 0, 0); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with position and dimensions 46 | /// 47 | /// Start X position (mm) 48 | /// Start Y position (mm) 49 | /// Start Z position (mm) 50 | /// End X position (mm) 51 | /// End Y position (mm) 52 | /// End Z position (mm) 53 | /// Duct width (mm) 54 | /// Duct height (mm) 55 | /// Base level elevation (mm) 56 | public DuctCreationInfo(double startX, double startY, double startZ, double endX, double endY, double endZ, 57 | double width, double height, double level = 0) 58 | { 59 | StartPoint = new JZPoint(startX, startY, startZ); 60 | EndPoint = new JZPoint(endX, endY, endZ); 61 | Width = width; 62 | Height = height; 63 | BaseLevel = level; 64 | } 65 | 66 | /// 67 | /// Duct start position (mm) 68 | /// 69 | [JsonProperty("startPoint")] 70 | public JZPoint StartPoint { get; set; } 71 | 72 | /// 73 | /// Duct end position (mm) 74 | /// 75 | [JsonProperty("endPoint")] 76 | public JZPoint EndPoint { get; set; } 77 | 78 | /// 79 | /// Duct width/diameter (mm) - for rectangular ducts this is width, for round ducts this is diameter 80 | /// 81 | [JsonProperty("width")] 82 | public double Width { get; set; } 83 | 84 | /// 85 | /// Duct height (mm) - used only for rectangular ducts 86 | /// 87 | [JsonProperty("height")] 88 | public double Height { get; set; } 89 | 90 | /// 91 | /// Base level elevation (mm) 92 | /// 93 | [JsonProperty("baseLevel")] 94 | public double BaseLevel { get; set; } 95 | 96 | /// 97 | /// Base offset (mm) 98 | /// 99 | [JsonProperty("baseOffset")] 100 | public double BaseOffset { get; set; } 101 | 102 | /// 103 | /// Duct system type 104 | /// 105 | [JsonProperty("systemType")] 106 | public string SystemType { get; set; } // Supply Air, Return Air, Exhaust Air 107 | 108 | /// 109 | /// Duct type 110 | /// 111 | [JsonProperty("ductType")] 112 | public string DuctType { get; set; } // Rectangular Duct, Round Duct, Oval Duct, etc. 113 | 114 | /// 115 | /// Duct type ID in Revit 116 | /// 117 | [JsonProperty("typeId")] 118 | public int TypeId { get; set; } 119 | 120 | /// 121 | /// Duct material 122 | /// 123 | [JsonProperty("material")] 124 | public string Material { get; set; } 125 | 126 | /// 127 | /// Insulation type 128 | /// 129 | [JsonProperty("insulationType")] 130 | public string InsulationType { get; set; } 131 | 132 | /// 133 | /// Insulation thickness (mm) 134 | /// 135 | [JsonProperty("insulationThickness")] 136 | public double InsulationThickness { get; set; } 137 | 138 | /// 139 | /// Additional options 140 | /// 141 | [JsonProperty("options")] 142 | public Dictionary Options { get; set; } 143 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/MEP/EquipmentCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.MEP; 28 | 29 | /// 30 | /// Information about equipment creation parameters 31 | /// 32 | public class EquipmentCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public EquipmentCreationInfo() 38 | { 39 | Location = new JZPoint(0, 0, 0); 40 | Options = new Dictionary(); 41 | } 42 | 43 | /// 44 | /// Constructor with position and dimensions 45 | /// 46 | /// X position (mm) 47 | /// Y position (mm) 48 | /// Z position (mm) 49 | /// Width (mm) 50 | /// Depth (mm) 51 | /// Height (mm) 52 | /// Base level elevation (mm) 53 | public EquipmentCreationInfo(double x, double y, double z, double width, double depth, double height, 54 | double level = 0) 55 | { 56 | Location = new JZPoint(x, y, z); 57 | Width = width; 58 | Depth = depth; 59 | Height = height; 60 | BaseLevel = level; 61 | } 62 | 63 | /// 64 | /// Equipment position (mm) 65 | /// 66 | [JsonProperty("location")] 67 | public JZPoint Location { get; set; } 68 | 69 | /// 70 | /// Equipment rotation around Z-axis (degrees) 71 | /// 72 | [JsonProperty("rotation")] 73 | public double Rotation { get; set; } 74 | 75 | /// 76 | /// Equipment width (mm) 77 | /// 78 | [JsonProperty("width")] 79 | public double Width { get; set; } 80 | 81 | /// 82 | /// Equipment depth (mm) 83 | /// 84 | [JsonProperty("depth")] 85 | public double Depth { get; set; } 86 | 87 | /// 88 | /// Equipment height (mm) 89 | /// 90 | [JsonProperty("height")] 91 | public double Height { get; set; } 92 | 93 | /// 94 | /// Base level elevation (mm) 95 | /// 96 | [JsonProperty("baseLevel")] 97 | public double BaseLevel { get; set; } 98 | 99 | /// 100 | /// Base offset (mm) 101 | /// 102 | [JsonProperty("baseOffset")] 103 | public double BaseOffset { get; set; } 104 | 105 | /// 106 | /// Equipment category 107 | /// 108 | [JsonProperty("category")] 109 | public string Category { get; set; } = 110 | "Mechanical Equipment"; // Mechanical Equipment, Electrical Equipment, Plumbing Fixtures 111 | 112 | /// 113 | /// Equipment type 114 | /// 115 | [JsonProperty("equipmentType")] 116 | public string EquipmentType { get; set; } // AHU, Pump, Fan, Panel, etc. 117 | 118 | /// 119 | /// Equipment system 120 | /// 121 | [JsonProperty("system")] 122 | public string System { get; set; } // HVAC, Electrical, Plumbing, Fire Protection 123 | 124 | /// 125 | /// Equipment family name 126 | /// 127 | [JsonProperty("familyName")] 128 | public string FamilyName { get; set; } 129 | 130 | /// 131 | /// Equipment type ID in Revit 132 | /// 133 | [JsonProperty("typeId")] 134 | public int TypeId { get; set; } 135 | 136 | /// 137 | /// Is electrical connected 138 | /// 139 | [JsonProperty("isElectricalConnected")] 140 | public bool IsElectricalConnected { get; set; } 141 | 142 | /// 143 | /// Requires ventilation 144 | /// 145 | [JsonProperty("requiresVentilation")] 146 | public bool RequiresVentilation { get; set; } 147 | 148 | /// 149 | /// Equipment power rating (watts) 150 | /// 151 | [JsonProperty("powerRating")] 152 | public double PowerRating { get; set; } 153 | 154 | /// 155 | /// Additional options 156 | /// 157 | [JsonProperty("options")] 158 | public Dictionary Options { get; set; } 159 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/MEP/PipeCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | using RevitMCPCommandSet.Models.Common; 26 | 27 | namespace RevitMCPCommandSet.Models.MEP; 28 | 29 | /// 30 | /// Information about pipe creation parameters 31 | /// 32 | public class PipeCreationInfo 33 | { 34 | /// 35 | /// Default constructor 36 | /// 37 | public PipeCreationInfo() 38 | { 39 | StartPoint = new JZPoint(0, 0, 0); 40 | EndPoint = new JZPoint(0, 0, 0); 41 | Options = new Dictionary(); 42 | } 43 | 44 | /// 45 | /// Constructor with position and dimensions 46 | /// 47 | /// Start X position (mm) 48 | /// Start Y position (mm) 49 | /// Start Z position (mm) 50 | /// End X position (mm) 51 | /// End Y position (mm) 52 | /// End Z position (mm) 53 | /// Pipe diameter (mm) 54 | /// Base level elevation (mm) 55 | public PipeCreationInfo(double startX, double startY, double startZ, double endX, double endY, double endZ, 56 | double diameter, double level = 0) 57 | { 58 | StartPoint = new JZPoint(startX, startY, startZ); 59 | EndPoint = new JZPoint(endX, endY, endZ); 60 | Diameter = diameter; 61 | BaseLevel = level; 62 | } 63 | 64 | /// 65 | /// Pipe start position (mm) 66 | /// 67 | [JsonProperty("startPoint")] 68 | public JZPoint StartPoint { get; set; } 69 | 70 | /// 71 | /// Pipe end position (mm) 72 | /// 73 | [JsonProperty("endPoint")] 74 | public JZPoint EndPoint { get; set; } 75 | 76 | /// 77 | /// Pipe diameter (mm) 78 | /// 79 | [JsonProperty("diameter")] 80 | public double Diameter { get; set; } 81 | 82 | /// 83 | /// Base level elevation (mm) 84 | /// 85 | [JsonProperty("baseLevel")] 86 | public double BaseLevel { get; set; } 87 | 88 | /// 89 | /// Base offset (mm) 90 | /// 91 | [JsonProperty("baseOffset")] 92 | public double BaseOffset { get; set; } 93 | 94 | /// 95 | /// Pipe system type 96 | /// 97 | [JsonProperty("systemType")] 98 | public string SystemType { get; set; } // Domestic Cold Water, Domestic Hot Water, Sanitary, etc. 99 | 100 | /// 101 | /// Pipe type 102 | /// 103 | [JsonProperty("pipeType")] 104 | public string PipeType { get; set; } // Standard, Copper, PVC, etc. 105 | 106 | /// 107 | /// Pipe type ID in Revit 108 | /// 109 | [JsonProperty("typeId")] 110 | public int TypeId { get; set; } = -1; 111 | 112 | /// 113 | /// Pipe material 114 | /// 115 | [JsonProperty("material")] 116 | public string Material { get; set; } 117 | 118 | /// 119 | /// Insulation type 120 | /// 121 | [JsonProperty("insulationType")] 122 | public string InsulationType { get; set; } 123 | 124 | /// 125 | /// Insulation thickness (mm) 126 | /// 127 | [JsonProperty("insulationThickness")] 128 | public double InsulationThickness { get; set; } 129 | 130 | /// 131 | /// Slope (%) 132 | /// 133 | [JsonProperty("slope")] 134 | public double Slope { get; set; } 135 | 136 | /// 137 | /// Additional options 138 | /// 139 | [JsonProperty("options")] 140 | public Dictionary Options { get; set; } 141 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Views/SheetCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Views; 27 | 28 | /// 29 | /// Information for sheet creation 30 | /// 31 | public class SheetCreationInfo 32 | { 33 | /// 34 | /// Default constructor 35 | /// 36 | public SheetCreationInfo() 37 | { 38 | Parameters = new Dictionary(); 39 | RevisionIds = new List(); 40 | } 41 | 42 | /// 43 | /// Sheet number 44 | /// 45 | [JsonProperty("sheetNumber")] 46 | public string SheetNumber { get; set; } = string.Empty; 47 | 48 | /// 49 | /// Sheet name 50 | /// 51 | [JsonProperty("sheetName")] 52 | public string SheetName { get; set; } = string.Empty; 53 | 54 | /// 55 | /// Title block type ID 56 | /// 57 | [JsonProperty("titleBlockTypeId")] 58 | public int TitleBlockTypeId { get; set; } 59 | 60 | /// 61 | /// Title block family name 62 | /// 63 | [JsonProperty("titleBlockFamilyName")] 64 | public string TitleBlockFamilyName { get; set; } = string.Empty; 65 | 66 | /// 67 | /// Title block type name 68 | /// 69 | [JsonProperty("titleBlockTypeName")] 70 | public string TitleBlockTypeName { get; set; } = string.Empty; 71 | 72 | /// 73 | /// Revision IDs to apply to the sheet 74 | /// 75 | [JsonProperty("revisionIds")] 76 | public List RevisionIds { get; set; } 77 | 78 | /// 79 | /// Additional parameters 80 | /// 81 | [JsonProperty("parameters")] 82 | public Dictionary Parameters { get; set; } 83 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Views/SheetInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Views; 27 | 28 | /// 29 | /// Sheet information data structure 30 | /// 31 | public class SheetInfo 32 | { 33 | /// 34 | /// Sheet element ID 35 | /// 36 | [JsonProperty("id")] 37 | public long Id { get; set; } 38 | 39 | /// 40 | /// Sheet unique ID 41 | /// 42 | [JsonProperty("uniqueId")] 43 | public string UniqueId { get; set; } 44 | 45 | /// 46 | /// Sheet number 47 | /// 48 | [JsonProperty("sheetNumber")] 49 | public string SheetNumber { get; set; } 50 | 51 | /// 52 | /// Sheet name 53 | /// 54 | [JsonProperty("sheetName")] 55 | public string SheetName { get; set; } 56 | 57 | /// 58 | /// Title block ID 59 | /// 60 | [JsonProperty("titleBlockId")] 61 | public int TitleBlockId { get; set; } 62 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Views/ViewCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Views; 27 | 28 | /// 29 | /// Information for view creation 30 | /// 31 | public class ViewCreationInfo 32 | { 33 | /// 34 | /// Default constructor 35 | /// 36 | public ViewCreationInfo() 37 | { 38 | Parameters = new Dictionary(); 39 | } 40 | 41 | /// 42 | /// View name 43 | /// 44 | [JsonProperty("name")] 45 | public string Name { get; set; } = string.Empty; 46 | 47 | /// 48 | /// View type (FloorPlan, CeilingPlan, Elevation, Section, 3D) 49 | /// 50 | [JsonProperty("viewType")] 51 | public string ViewType { get; set; } = "FloorPlan"; 52 | 53 | /// 54 | /// Level elevation in millimeters (for plan views) 55 | /// 56 | [JsonProperty("levelElevation")] 57 | public double LevelElevation { get; set; } 58 | 59 | /// 60 | /// View detail level (Coarse, Medium, Fine) 61 | /// 62 | [JsonProperty("detailLevel")] 63 | public string DetailLevel { get; set; } = "Medium"; 64 | 65 | /// 66 | /// View scale (e.g., 100 for 1:100) 67 | /// 68 | [JsonProperty("scale")] 69 | public int Scale { get; set; } = 100; 70 | 71 | /// 72 | /// View family type name 73 | /// 74 | [JsonProperty("viewFamilyTypeName")] 75 | public string ViewFamilyTypeName { get; set; } = string.Empty; 76 | 77 | /// 78 | /// Template view unique ID to apply 79 | /// 80 | [JsonProperty("templateId")] 81 | public string TemplateId { get; set; } = string.Empty; 82 | 83 | /// 84 | /// View direction for elevation/section views 85 | /// 86 | [JsonProperty("direction")] 87 | public Point Direction { get; set; } 88 | 89 | /// 90 | /// Additional parameters 91 | /// 92 | [JsonProperty("parameters")] 93 | public Dictionary Parameters { get; set; } 94 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Models/Views/ViewportCreationInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | using Newtonsoft.Json; 25 | 26 | namespace RevitMCPCommandSet.Models.Views; 27 | 28 | /// 29 | /// Information for viewport creation 30 | /// 31 | public class ViewportCreationInfo 32 | { 33 | /// 34 | /// Default constructor 35 | /// 36 | public ViewportCreationInfo() 37 | { 38 | Parameters = new Dictionary(); 39 | } 40 | 41 | /// 42 | /// Sheet ID to place viewport on 43 | /// 44 | [JsonProperty("sheetId")] 45 | public int SheetId { get; set; } 46 | 47 | /// 48 | /// View ID to place in viewport 49 | /// 50 | [JsonProperty("viewId")] 51 | public int ViewId { get; set; } 52 | 53 | /// 54 | /// X position on sheet in millimeters 55 | /// 56 | [JsonProperty("positionX")] 57 | public double PositionX { get; set; } 58 | 59 | /// 60 | /// Y position on sheet in millimeters 61 | /// 62 | [JsonProperty("positionY")] 63 | public double PositionY { get; set; } 64 | 65 | /// 66 | /// Viewport type ID 67 | /// 68 | [JsonProperty("viewportTypeId")] 69 | public int ViewportTypeId { get; set; } 70 | 71 | /// 72 | /// Whether to display the view title 73 | /// 74 | [JsonProperty("displayTitle")] 75 | public bool? DisplayTitle { get; set; } 76 | 77 | /// 78 | /// Override scale for the viewport 79 | /// 80 | [JsonProperty("scaleOverride")] 81 | public int ScaleOverride { get; set; } 82 | 83 | /// 84 | /// Viewport label text 85 | /// 86 | [JsonProperty("labelText")] 87 | public string LabelText { get; set; } = string.Empty; 88 | 89 | /// 90 | /// Rotation angle in degrees 91 | /// 92 | [JsonProperty("rotation")] 93 | public double Rotation { get; set; } 94 | 95 | /// 96 | /// Additional parameters 97 | /// 98 | [JsonProperty("parameters")] 99 | public Dictionary Parameters { get; set; } 100 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/RevitMCPCommandSet.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | latest 6 | x64 7 | true 8 | true 9 | Debug R20;Debug R21;Debug R22;Debug R23;Debug R24;Debug R25 10 | $(Configurations);Release R20;Release R21;Release R22;Release R23;Release R24;Release R25 11 | 12 | 13 | 14 | 2020 15 | net48 16 | 17 | 18 | 2021 19 | net48 20 | 21 | 22 | 2022 23 | net48 24 | 25 | 26 | 2023 27 | net48 28 | 29 | 30 | 2024 31 | net48 32 | 33 | 34 | 2025 35 | net8.0-windows10.0.19041.0 36 | 37 | 38 | 39 | Program 40 | C:\Program Files\Autodesk\Revit $(RevitVersion)\Revit.exe 41 | /language ENG 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Services/DeleteElementEventHandler.cs: -------------------------------------------------------------------------------- 1 | //using Autodesk.Revit.UI; 2 | //using RevitMCPSDK.API.Interfaces; 3 | 4 | //namespace RevitMCPCommandSet.Services 5 | //{ 6 | // public class DeleteElementEventHandler : IExternalEventHandler, IWaitableExternalEventHandler 7 | // { 8 | // // 执行结果 9 | // public bool IsSuccess { get; private set; } 10 | 11 | // // 成功删除的元素数量 12 | // public int DeletedCount { get; private set; } 13 | // // 状态同步对象 14 | // public bool TaskCompleted { get; private set; } 15 | // private readonly ManualResetEvent _resetEvent = new ManualResetEvent(false); 16 | // // 要删除的元素ID数组 17 | // public string[] ElementIds { get; set; } 18 | // // 实现IWaitableExternalEventHandler接口 19 | // public bool WaitForCompletion(int timeoutMilliseconds = 10000) 20 | // { 21 | // return _resetEvent.WaitOne(timeoutMilliseconds); 22 | // } 23 | // public void Execute(UIApplication app) 24 | // { 25 | // try 26 | // { 27 | // var doc = app.ActiveUIDocument.Document; 28 | // DeletedCount = 0; 29 | // if (ElementIds == null || ElementIds.Length == 0) 30 | // { 31 | // IsSuccess = false; 32 | // return; 33 | // } 34 | // // 创建待删除元素ID集合 35 | // List elementIdsToDelete = new List(); 36 | // List invalidIds = new List(); 37 | // foreach (var idStr in ElementIds) 38 | // { 39 | // if (int.TryParse(idStr, out int elementIdValue)) 40 | // { 41 | // var elementId = new ElementId(elementIdValue); 42 | // // 检查元素是否存在 43 | // if (doc.GetElement(elementId) != null) 44 | // { 45 | // elementIdsToDelete.Add(elementId); 46 | // } 47 | // } 48 | // else 49 | // { 50 | // invalidIds.Add(idStr); 51 | // } 52 | // } 53 | // if (invalidIds.Count > 0) 54 | // { 55 | // TaskDialog.Show("警告", $"以下ID无效或元素不存在:{string.Join(", ", invalidIds)}"); 56 | // } 57 | // // 如果有可删除的元素,则执行删除 58 | // if (elementIdsToDelete.Count > 0) 59 | // { 60 | // using (var transaction = new Transaction(doc, "Delete Elements")) 61 | // { 62 | // transaction.Start(); 63 | 64 | // // 批量删除元素 65 | // ICollection deletedIds = doc.Delete(elementIdsToDelete); 66 | // DeletedCount = deletedIds.Count; 67 | 68 | // transaction.Commit(); 69 | // } 70 | // IsSuccess = true; 71 | // } 72 | // else 73 | // { 74 | // TaskDialog.Show("错误", "没有有效的元素可以删除"); 75 | // IsSuccess = false; 76 | // } 77 | // } 78 | // catch (Exception ex) 79 | // { 80 | // TaskDialog.Show("错误", "删除元素失败: " + ex.Message); 81 | // IsSuccess = false; 82 | // } 83 | // finally 84 | // { 85 | // TaskCompleted = true; 86 | // _resetEvent.Set(); 87 | // } 88 | // } 89 | // public string GetName() 90 | // { 91 | // return "删除元素"; 92 | // } 93 | // } 94 | //} 95 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Services/GetCurrentViewInfoEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using RevitMCPCommandSet.Models.Common; 3 | using RevitMCPSDK.API.Interfaces; 4 | 5 | namespace RevitMCPCommandSet.Services 6 | { 7 | public class GetCurrentViewInfoEventHandler : IExternalEventHandler, IWaitableExternalEventHandler 8 | { 9 | // 执行结果 10 | public ViewInfo ResultInfo { get; private set; } 11 | 12 | // 状态同步对象 13 | public bool TaskCompleted { get; private set; } 14 | private readonly ManualResetEvent _resetEvent = new ManualResetEvent(false); 15 | 16 | // 实现IWaitableExternalEventHandler接口 17 | public bool WaitForCompletion(int timeoutMilliseconds = 10000) 18 | { 19 | return _resetEvent.WaitOne(timeoutMilliseconds); 20 | } 21 | 22 | public void Execute(UIApplication app) 23 | { 24 | try 25 | { 26 | var uiDoc = app.ActiveUIDocument; 27 | var doc = uiDoc.Document; 28 | var activeView = doc.ActiveView; 29 | 30 | ResultInfo = new ViewInfo 31 | { 32 | #if REVIT2024_OR_GREATER 33 | Id = (int)activeView.Id.Value, 34 | #else 35 | Id = activeView.Id.IntegerValue, 36 | #endif 37 | UniqueId = activeView.UniqueId, 38 | Name = activeView.Name, 39 | ViewType = activeView.ViewType.ToString(), 40 | IsTemplate = activeView.IsTemplate, 41 | Scale = activeView.Scale, 42 | DetailLevel = activeView.DetailLevel.ToString(), 43 | }; 44 | } 45 | catch (Exception ex) 46 | { 47 | TaskDialog.Show("error", "获取信息失败"); 48 | } 49 | finally 50 | { 51 | TaskCompleted = true; 52 | _resetEvent.Set(); 53 | } 54 | } 55 | 56 | public string GetName() 57 | { 58 | return "获取当前视图信息"; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Services/GetSelectedElementsEventHandler.cs: -------------------------------------------------------------------------------- 1 | using Autodesk.Revit.UI; 2 | using RevitMCPCommandSet.Models.Common; 3 | using RevitMCPSDK.API.Interfaces; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace RevitMCPCommandSet.Services 11 | { 12 | public class GetSelectedElementsEventHandler : IExternalEventHandler, IWaitableExternalEventHandler 13 | { 14 | // 执行结果 15 | public List ResultElements { get; private set; } 16 | 17 | // 状态同步对象 18 | public bool TaskCompleted { get; private set; } 19 | private readonly ManualResetEvent _resetEvent = new ManualResetEvent(false); 20 | 21 | // 限制返回的元素数量 22 | public int? Limit { get; set; } 23 | 24 | // 实现IWaitableExternalEventHandler接口 25 | public bool WaitForCompletion(int timeoutMilliseconds = 10000) 26 | { 27 | return _resetEvent.WaitOne(timeoutMilliseconds); 28 | } 29 | 30 | public void Execute(UIApplication app) 31 | { 32 | try 33 | { 34 | var uiDoc = app.ActiveUIDocument; 35 | var doc = uiDoc.Document; 36 | 37 | // 获取当前选中的元素 38 | var selectedIds = uiDoc.Selection.GetElementIds(); 39 | var selectedElements = selectedIds.Select(id => doc.GetElement(id)).ToList(); 40 | 41 | // 应用数量限制 42 | if (Limit.HasValue && Limit.Value > 0) 43 | { 44 | selectedElements = selectedElements.Take(Limit.Value).ToList(); 45 | } 46 | 47 | // 转换为ElementInfo列表 48 | ResultElements = selectedElements.Select(element => new ElementInfo 49 | { 50 | #if REVIT2024_OR_GREATER 51 | Id = element.Id.Value, 52 | #else 53 | Id = element.Id.IntegerValue, 54 | #endif 55 | UniqueId = element.UniqueId, 56 | Name = element.Name, 57 | Category = element.Category?.Name 58 | }).ToList(); 59 | } 60 | catch (Exception ex) 61 | { 62 | TaskDialog.Show("Error", "获取选中元素失败: " + ex.Message); 63 | ResultElements = new List(); 64 | } 65 | finally 66 | { 67 | TaskCompleted = true; 68 | _resetEvent.Set(); 69 | } 70 | } 71 | 72 | public string GetName() 73 | { 74 | return "获取选中元素"; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /revit-mcp-commandset/Utils/DeleteWarningSuperUtils.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | namespace RevitMCPCommandSet.Utils; 25 | 26 | public class DeleteWarningSuperUtils : IFailuresPreprocessor 27 | { 28 | public int NumberErr; 29 | 30 | public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor) 31 | { 32 | FailureProcessingResult failureProcessingResult; 33 | var failList = failuresAccessor.GetFailureMessages(); 34 | if (failList.Count != 0) 35 | { 36 | foreach (var failure in failList) 37 | { 38 | var s = failure.GetSeverity(); 39 | var failureDefinitionId = failure.GetFailureDefinitionId(); 40 | 41 | if (s == FailureSeverity.Warning) 42 | { 43 | if (failureDefinitionId == BuiltInFailures.GeneralFailures.DuplicateValue) 44 | failuresAccessor.DeleteWarning(failure); 45 | else 46 | failuresAccessor.DeleteWarning(failure); 47 | } 48 | else if (s == FailureSeverity.Error) 49 | { 50 | failuresAccessor.ResolveFailure(failure); 51 | NumberErr += 1; 52 | } 53 | } 54 | 55 | failureProcessingResult = FailureProcessingResult.ProceedWithCommit; 56 | } 57 | else 58 | { 59 | failureProcessingResult = FailureProcessingResult.Continue; 60 | } 61 | 62 | return failureProcessingResult; 63 | } 64 | } -------------------------------------------------------------------------------- /revit-mcp-commandset/Utils/HandleDuplicateTypeUtils.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RevitAPI-Solutions 3 | // Copyright (c) Duong Tran Quang (DTDucas) (baymax.contact@gmail.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | // 23 | 24 | namespace RevitMCPCommandSet.Utils; 25 | 26 | public class HandleDuplicateTypeUtils : IDuplicateTypeNamesHandler 27 | { 28 | public DuplicateTypeAction OnDuplicateTypeNamesFound(DuplicateTypeNamesHandlerArgs args) 29 | { 30 | return DuplicateTypeAction.UseDestinationTypes; 31 | } 32 | } --------------------------------------------------------------------------------