OpenAI GPT to assist with Revit coding

I have attempted to make a GPT on the OpenAI platform to assist in programming Revit. One needs the paid version of ChatGPT to access it.
image
https://chat.openai.com/g/g-7gcy5wueV-bim-coding-coach
It seems to give explanations and working code (at least in Python) like in this chat:


Examples of code it made:



I gave it training data for C# API, and DesignScript, not just Python, but that will need further testing.
Should I limit the coaching output and try to make it spit out mostly code?

These are its instructions:

Assistant is an expert in programming Autodesk Revit versions 2022 and newer, with a strong emphasis on C Sharp, Python 3, DesignScript, and using nodes for Dynamo. It offers specialized guidance, code examples, and troubleshooting advice for these programming languages and tools, specifically tailored to Revit's newer versions. The GPT provides detailed explanations and practical solutions for programming challenges in Revit, helping users optimize their workflow through efficient and innovative use of the Revit API, DesignScript, Python, and Dynamo nodes. It keeps up-to-date with the latest features and best practices for Revit 2022 and beyond.
7 Likes

It has some DesignScript functionality after some iterations.



Initial prompt:

use https://primer.dynamobim.org/07_Code-Block/7-2_Design-Script-syntax.html and show me something new with designscript
1 Like

I have made a GitHub repository to share how this GPT is made and maybe we can collaborate on improving it.

Latest update was to add hotkeys:

Hotkeys for this GPT:
h :  Show hotkeys for this GPT
c :  Show complete code without comments or empty lines, do not write any explanation outside of the code itself. Show code in language being discussed: cpython3, DesignScript, or C#.
e :  Explain the concept being discussed
i :  Show Instructions for this GPT
4 Likes

@truevis ,

it works with ChatGPT 4 ?

KR

Andreas

Very Cool @truevis ,

Will surely check this out, I’ll keep you updated if I’ve used it.

Yes, GPTs only are accessible to subscribers of GPT Plus at $20/mo.

What I have been saying since I subscribed, is that I cannot afford not to pay it. It has capabilities to help my consultancy with a much higher value than that.

For example, I wanted something that will Zip a folder with a timestamp in the Zip filename. I used the Grimoire GPT and it wrote the whole app in python in a few prompts.



Code at Python script to automatically compress a specified folder into a ZIP file with a unique, time-stamped filename. Ideal for regular backups and archiving. · GitHub

1 Like

Nice Work! Was also planning to do that.
Will test your GPT. First tests show same common mistakes that GPT4 is making. So I think this just needs more content for training.

Two questions:

  • Can you try to force full code output instead of code snippets with filler comments?
  • Can you force verifying methods by looking up RevitAPIdocs.com?

Are there now any costs for you training and using the GPT?

Try typing “c” has a hotkey.
c : Show complete code without comments or empty lines, do not write any explanation outside of the code itself. Show code in language being discussed: cpython3, DesignScript, or C#.
You can also emphasize than in your prompts.

Try referencing search results from http://RevitAPIdocs.com EG ViewFamilyType Methods in your prompt. LMK if it helps.

There is probably a way to get that into the GPT’s training data more directly,

The GPT doesn’t cost me anything if people use it. I also don’t see what people use it for.

2 Likes

Exelente idea

Muchas gracias amigo

Could you use any open source GPT platform? I have tried it on ms copilot-
1

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument

# Placeholder for retrieving elements 
from Revit
# Replace these with actual calls to get elements from your Revit model
nodes = []  # Your code to get nodes
edges = []  # Your code to get edges with weights

# Define Dijkstra's algorithm
def dijkstra(graph, start):
    shortest_paths = {start: (None, 0)}
    current_node = start
    visited = set()

    while current_node is not None:
        visited.add(current_node)
        destinations = graph[current_node]
        weight_to_current_node = shortest_paths[current_node][1]

        for next_node, weight in destinations.items():
            weight = weight_to_current_node + weight
            if next_node not in shortest_paths:
                shortest_paths[next_node] = (current_node, weight)
            else:
                current_shortest_weight = shortest_paths[next_node][1]
                if current_shortest_weight > weight:
                    shortest_paths[next_node] = (current_node, weight)

        next_destinations = {node: shortest_paths[node] for node in shortest_paths if node not in visited}
        if not next_destinations:
            return shortest_paths

        current_node = min(next_destinations, key=lambda k: next_destinations[k][1])

    return shortest_paths

# Example usage
graph = {
    'A': {'B': 1, 'C': 4},
    'B': {'A': 1, 'C': 2, 'D': 5},
    'C': {'A': 4, 'B': 2, 'D': 1},
    'D': {'B': 5, 'C': 1}
}
start_node = 'A'
shortest_paths = dijkstra(graph, start_node)
print(shortest_paths)

One can write specialized chatbots with vector databases and text search, but it is rather complicated. I have been doing that for building specifications, etc.