CLAUDE Controls Revit! (AI & MCP Tutorial)
Pro BIM NK
0:00 / 0:00
CLAUDE Controls Revit! (AI & MCP Tutorial)
451 просмотр · 1 мес. назад
Pro BIM NK
38 подписчиков
451 просмотр · 1 мес. назад
Welcome to Lecture 4 of our Autodesk Revit 2027 series! In this video, we ditch the traditional manual work and Dynamo errors, and instead, we connect Claude AI directly to Revit using the Model Context Protocol (MCP) and pyRevit. Watch as Claude writes Python scripts, executes them in Revit, and generates scaled grids and dimensions on autopilot!
📄 Download all Codes, Commands & Prompts (Word File):
https://1drv.ms/w/c/B31CFBF8D94ECE25/...
🔗 TIMESTAMPS
00:00 - Downloading the MCP & pyRevit Packages
00:31 - Configuring Revit & Installing the MCP Extension
02:40 - Writing the Python Tool in VS Code (grid_tool.py)
03:56 - Claude AI Controlling Revit in Action (Grids & Dimensions)
⚠️ IMPORTANT: PRE-INSTALLATION STEPS (pyRevit)
1) Close Revit: A necessary step to prevent file conflicts during installation. Make sure to save your projects and completely close all running Autodesk Revit windows and processes.
2) Go to the GitHub Releases page and download the appropriate installer file.
3) Under the Assets section, download the executable installer file and run it.
4) Open Revit and verify the pyRevit activation.
💻 TERMINAL / POWERSHELL COMMANDS
Command 1 (Clone Repository):
New-Item -ItemType Directory -Path "C:\RevitMCP" -Force
git clone https://github.com/mcp-servers-for-re... "C:\RevitMCP\mcp-server-for-revit-python.extension"
Command 2 (Run UV):
C:\Users\office\.local\bin\uv.exe run --directory "C:\RevitMCP\mcp-server-for-revit-python.extension" --with "mcp[cli]"
Command 3 (Copy grid_tool):
Copy-Item -Path "C:\RevitMCP\mcp-server-for-revit-python.extension\mcp-server-for-revit-python.extension\tools\grid_tool.py" -Destination "C:\Users\office\AppData\Roaming\pyRevit\Extensions\mcp-server-for-revit-python.extension\tools\" -Force
Command 4 (Copy Extension):
Copy-Item -Path "C:\RevitMCP\mcp-server-for-revit-python.extension\mcp-server-for-revit-python.extension\*" -Destination "C:\Users\office\AppData\Roaming\pyRevit\Extensions" -Recurse -Force
🐍 VS CODE: PYTHON SCRIPT (grid_tool.py)
from mcp.server.fastmcp import FastMCP
def register_grid_tools(mcp: FastMCP, make_revit_request):
@mcp.tool()
async def create_revit_grid(x1: float, y1: float, x2: float, y2: float, name: str = None):
"""Create a new Grid in the active Revit model using line start (x1, y1) and end (x2, y2) points."""
payload = {"x1": x1, "y1": y1, "x2": x2, "y2": y2, "name": name}
response = await make_revit_request("create_grid", payload)
return str(response)
🤖 CLAUDE AI PROMPTS USED IN THIS VIDEO
Prompt 1:
"Yes, try creating the grids using execute_revit_code instead."
Prompt 2 (Fixing Meters to Feet scale):
"It worked perfectly! However, the grids are too small because my coordinates were in Meters and Revit API expects Feet. I have undone the previous creation. Please run execute_revit_code again to create the exact same 12 grids, but this time, multiply all the coordinate values (x1, y1, x2, y2) by 3.28084 inside your script so they are scaled correctly to Meters."
Prompt 3 (Adding Dimensions):
"Awesome! Now I need you to add dimensions (cotations) to these newly created grids in the active view using execute_revit_code.
Please write and execute a Python script that does the following inside a Transaction:
Collect the vertical grids (named '1' to '6'). Extract their Curve.Reference and add them to a ReferenceArray.
Create a horizontal Line (using DB.Line.CreateBound) placed below the grids (e.g., at Y = -10 feet) to position the dimension string.
Create a dimension for the vertical grids using doc.Create.NewDimension(doc.ActiveView, horizontal_line, vertical_refs).
Repeat the exact same process for the horizontal grids (named 'A' to 'F'). Collect their references, create a vertical Line placed to the left of the grids (e.g., at X = -10 feet), and use doc.Create.NewDimension.
Print a success message once done."
📺 Watch Previous Lecture (I Tried Dynamo for Grids... It Failed!):
• Tried Dynamo for Grids... It Failed! (Time...
🏷️ Tags:
#Revit2027 #ClaudeAI #BIMAutomation #RevitAPI #pyRevit #MCP #BIM #RevitTutorial #PythonForRevit