If you are on Twitter or social media in general, you have probably heard of/seen a tool called ChatGPT. It is an AI system that allows for conversational dialogue between you (human) and the AI (🤖).
People have used it to generate all sorts of cool stuff in the AEC world.
In addition to these interactions, people in the coding community have asked ChatGPT to write code for them. This has caused sites like Stack Overflow to implement new policies around asking questions based on code generated by ChatGPT.
We also had questions on the Dynamo forum that were sparked via ChatGPT.
With this in mind, I thought trying the tool was worth my time. So I did. And the results surprised me a bit.
I asked ChatGPT to generate a Python script for Dynamo for Revit to delete all the walls in my Revit model. And here is what it came up with:
For the most part, this script is complete. It imports all Python references, collects all walls (types and instances), and wraps the deletion in a transaction.
However, one part it missed on line #10 is that we cannot truly delete all wall types from a Revit model (because it does not know Revit or the API). This is because stacked walls depend on those types (stacked wall types require at least one other primary wall type in the model).
This is one of those examples where the human using the script needs to know what is up. In my case, I have used the Revit API, so I knew this was the case (although a google search of the error received would have also enlightened us).
So to use the generated Python, we had to add one more chunk of code, WhereElementIsNotElementType(). This forces the collector to only focus on the placed instances in the model, which is perfect for this use case.
Results in this code:
As with any new technology, you will see people complaining about it, misusing it, or scoffing at it.
However, I believe this technology is remarkable if you approach it with the appropriate expectations.
Take Python for Dynamo, for example: Go ask it how to write scripts, but do not just copy and paste and expect it to work 100% of the time. That isn’t fair. That is the same as googling something and taking it as truth without your research.
My suggested process is as follows:
Ask ChatGPT your question.
Make it concise and not overly complex. Act like you are asking this of someone on the Dynamo forum. Good Example: “Show me in Python how you pin an element in Revit with Dynamo.” Bad Example: “Write me a python script to auto-dimension all plans in my model and place them on a sheet and print the sheet to PDF”
If you asked these two questions on the forum, you would likely get an answer for #1 but not for #2. You would probably get told to do more research for #2.
Search APIDocs.co for the API calls that are being generated. Do they exist? If not, is there another one that sounds similar? If nothing is found, ChatGPT probably made up the API for you, which, unfortunately, is unpossible*.
But John, what if I don’t know what to look for in the API or for Python in Dynamo?
Well, first of all, I completely understand that feeling. I have been
fighting with working in Dynamo and Revit for a few years now and have an idea of what to look out for when checking out these AI-generated Python scripts. This is part of the reason I could get that script to work reasonably quickly.
If you aren’t quite there yet and are at the “I want to learn some Python” part of your Dynamo journey, I encourage you to check out my course, “Dynamo for Revit: Programming with Python.”
This course is made with the Revit user in mind and is structured to take you from someone who has never written python to someone who can search API docs, use the code and get some working python in Dynamo.
If you head over and sign up now, you can get a $10 discount using the code “ChatGPTBroughtMeHere” through the end of the month (January 31st, 2023, 11:59 pm). This results in the course being $89.99 before tax (USD).
I plan on doing a few videos on ChatGPT and using the code in Dynamo because I think it is a valuable tool to add to our toolbox as long as we use it wisely.
And if you missed it, check out the full video of the script in action here:
I encourage you to test and check out these exciting new things in AI (with appropriate expectations) while remaining optimistic and not overly critical.
And, most importantly, Have Fun!
Pingback: 건축가의 ChatGPT 사용 분야 – A.I.TECT