Long time no see! Happy New Year. Here I am again with a host of stuff:
Happy New Year to all the brilliant minds in the Revit API developer community! Wishing you a year filled with joy, success in all your endeavors, and may your coding adventures be fruitful and rewarding. Peace and happiness to all.
Unfortunately, in the past few months, I keep being reminded of the so-called Chinese curse: May you live in interesting times. In fact, it appears that there is no known Chinese equivalent; the closest is "Better to be a dog in times of tranquility than a human in times of chaos", 寧為太平犬,不做亂世人. Taking a completely opposite view, surveying an apparently collapsing China, Mao Zedong coolly observed that there was “great disorder under the Heavens and the situation is excellent.” Interesting times indeed.
As I mentioned in November, my retirement is nearing and I took time off in the past two months.
I am back again now and thinking about how to wind up my activities before retiring towards the middle of the year.
Meanwhile, I am mesmerised by the advancements in AI and LLMs. I am confident that already today, most of the repetitive questions that keep coming up in the Revit API forum can be answered by proper queries to one of the LLMs.
Today, I would like to highlight three new non-repetitive threads from the past week here, and also list a few of the AI-related titbits that caught my attention.
Luiz Henrique @ricaun Cassettari shared his multi-version NUnit testing framework for Revit API, saying:
Hello everyone, after some years of development my Test framework for Revit API is released.
ricaun.RevitTest is a multi-version NUnit
testing framework for Revit API.
It supports all releases from Revit 2019 up to Revit 2025.
Features:
The whole project is open-source with all the utility packages.
Here is his 34-minute video on Open-Source RevitTest:
The best way to start is by downloading the sample RevitTest project on GitHub.
Please use the RevitTest discussions area for help and discussion.
@ricaun also shared the results of his research on Revit icons support high-resolution display:
Unlike AutoCAD, the Revit UI itself does not provide this support, but Revit add-ins can do so, using TIFF files to allow multiple resolutions of the same image in a single file, exactly as the Autodesk Icon Design Guidelines suggest, e.g., 5 DPI png images (100%, 150%, 200% 300% and 400%) to support clear displays on high-resolution monitors.
Next step: update all add-ins to use TIFF files instead of ICO files to support high-resolution monitors, cf. the ten-minute video explaining how
to create multi-dpi tiff
icons for Revit:
Another great forum contribution comes from Brian @BriCircuitBIM Miller, explaining the relationships between viewports, view types, and title types in order to change viewport type via API. Here is his full explanation:
If your goal is to change the viewport type based on the view title name (e.g., "Title, No Scale, Line"), here's how you can proceed:
The key is to work with ElementType
objects within the OST_ViewportLabel
category, which represents viewport title types:
// Retrieve all viewport types (family symbols) in the project
FilteredElementCollector collector = new FilteredElementCollector(doc)
.OfClass(typeof(FamilySymbol))
.OfCategory(BuiltInCategory.OST_ViewportLabel);
string targetViewportTypeName = "Title, No Scale, Line";
FamilySymbol targetViewportType = collector
.Cast<FamilySymbol>()
.FirstOrDefault(fs => fs.Name.Equals(targetViewportTypeName, StringComparison.OrdinalIgnoreCase));
if (targetViewportType == null)
{
TaskDialog.Show("Error", "The specified viewport type was not found.");
return;
}
Once you've identified the desired viewport type, you can update specific viewports programmatically using the Viewport.ChangeTypeId
method:
FilteredElementCollector viewportCollector = new FilteredElementCollector(doc)
.OfClass(typeof(Viewport));
using (Transaction trans = new Transaction(doc, "Change Viewport Types"))
{
try
{
trans.Start();
foreach (Viewport viewport in viewportCollector.Cast<Viewport>())
{
Autodesk.Revit.DB.View view = doc.GetElement(viewport.ViewId) as Autodesk.Revit.DB.View;
// Example: Update only viewports associated with Drafting Views
if (view != null && view.ViewType == ViewType.DraftingView)
{
viewport.ChangeTypeId(targetViewportType.Id);
}
}
trans.Commit();
}
catch (Exception ex)
{
trans.RollBack();
TaskDialog.Show("Error", $"An error occurred: {ex.Message}");
}
}
Key insights for the API limitations why your diagnostic code returns nothing: Your initial code attempts to retrieve viewport types by filtering with .OfClass(typeof(View)). However:
ElementType
objects under the OST_ViewportLabel
category.Here's a diagnostic script to list all available viewport types by name:
FilteredElementCollector collector = new FilteredElementCollector(doc)
.OfClass(typeof(FamilySymbol))
.OfCategory(BuiltInCategory.OST_ViewportLabel);
StringBuilder viewportTypeNames = new StringBuilder("Available Viewport Types:\n");
foreach (FamilySymbol type in collector.Cast<FamilySymbol>())
{
viewportTypeNames.AppendLine(type.Name);
}
TaskDialog.Show("Viewport Types", viewportTypeNames.ToString());
For users working in Dynamo:
Sometimes, my NLU (Natural Language Understanding) system doesn't interpret things perfectly, so please feel free to let me know if any part of this explanation is unclear or inaccurate.
This response stems from my own challenges when attempting to programmatically change legend viewport titles in Revit.
After spending two days meticulously experimenting, I concluded that it is not possible to change a legend viewport type unless that type already exists in the project.
The breakthrough came when I shifted my focus to identifying viewport types that were already present in the project.
By filtering and listing these existing types, I was able to determine which one to use as the replacement.
For anyone facing similar struggles, I highly recommend starting with a diagnostic approach: gather all available viewport types using the FilteredElementCollector
and confirm their names match your desired title type.
This ensures you're working within the constraints of your project's current configuration.
Thank you very much, Brian, for documenting and explaining this!
Moustafa Khalil of SharpBIM (GitHub) adds:
Fetching Viewport Types is a bit tricky. I wrote an article that might help about purging viewport types, i.e., deleting the unused ones.
In general, the process of identifying elements like Viewport Types without a defined class in Revit is challenging.
ViewportType
is categorized as an ElementType
, which is too broad to be helpful.
An alternative approach is to indirectly identify purgeable Viewport Types by targeting parameters.
Since ViewportType
is a system family, all instances must have the Show Extension Line
parameter, stored in the BuiltInParameter
VIEWPORT_ATTR_SHOW_EXTENSION_LINE
.
This Boolean parameter (0 or 1) can be used in a filter rule.
By applying the ParameterFilterRuleFactory
CreateGreaterOrEqualRule
with a value of 0, all types possessing this parameter can be identified.
You can try this code to change the viewport type and read more about this code in this article:
// create filterRule to be used in collection
var rule = ParameterFilterRuleFactory.CreateGreaterOrEqualRule(
new ElementId(BuiltInParameter.VIEWPORT_ATTR_SHOW_EXTENSION_LINE),
0
);
// define which type name you are looking for
var nameRule = ParameterFilterRuleFactory.CreateEqualsRule(
new ElementId(BuiltInParameter.ALL_MODEL_TYPE_NAME),
"Titre sans ligne"
);
// get all elements that comply to this rule
var viewPortTypes = new FilteredElementCollector(doc)
.WhereElementIsElementType()
.OfCategory(BuiltInCategory.INVALID)
.WherePasses(new ElementParameterFilter(rule))
.WherePasses(new ElementParameterFilter(nameRule))
.ToElementIds();
// should be only one result
var viewPortTypeId = viewPortTypes.FirstOrDefault();
if (viewPortTypeId != null)
{
var vp = ... ; // the viewport you need to change
Trans.Start();
vp.ChangeTypeId(viewPortTypeId);
Trans.Commit();
}
Many thanks to Moustafa as well.
Transitioning from the pure Revit API to more AI-related topics, Jacqueline Rohrmann shared a Revit add-in providing interactive ChatGPT interface to run Revit commands on LinkedIn. You can check out the comments on that post to see what people think of it.
Now that LLMs are rapidly improving their code generation capabilities, what will happen to professional software developers? Well, writing code is one thing, and deep experience and expertise is something completely different. An interesting article from 2005 by Hubert L. Dreyfus and Stuart E. Dreyfus analyses Expertise in Real World Contexts.
Abstract: In this paper we describe a five-stage phenomenological model of skill acquisition, of which expertise is the highest stage. Contrary to the claims of knowledge engineers, we argue that expertise in general, and medical expertise in particular, cannot be captured in rule-based expert systems, since expertise is based on the making of immediate, unreflective situational responses; intuitive judgment is the hallmark of expertise. Deliberation is certainly used by experts, if time permits, but it is done for the purpose of improving intuition, not replacing it. The best way to avoid mistakes is to take responsibility for them when they occur, rather than try to prevent them by foolproof rules. In bureaucratic societies, however, there is the danger that expertise may be diminished through over-reliance on calculative rationality.
The five stages they identify are pretty obvious:
LLMs are currently challenged to reach the higher stages, and it is worthwhile pondering that.
In December, OpenAI released o1
, the most advanced LLM so far, and showed off the reasoning capabilities of its unreleased successor o3
.
o3
is the first LLM to be able to partially solve
the ARC-AGI Abstraction and Reasoning Corpus for Artificial General Intelligence test.\
The test is designed to be pretty simple for a human and very hard for an AI. I did it myself and found it very easy, next to trivial, once I got the hang of it.
It is very worthwhile trying it out for yourself to get an idea of the tasks that challenge an AI, and to read the explanation of what aspects LLMs do and do not get right in the evaluation of the OpenAI o3 breakthrough high score on ARC-AGI-PUB.
For a quick overview of what going on in general, check out the top 10 AI breakthroughs & controversies of 2024
For an even more basic introduction to the fundamentals of what started off the current LLM revolution, one might want to meet transformers: the Google breakthrough that rewrote AI's roadmap – how attention replaced recurrence and changed the rules of AI.
December also saw ther release of the video generation AIs, Sora2 and Veo2. Here is a short movie by Veo 2 that gives you an idea of the state of the art.
Another overview of the current state of AI affairs is provided by the LangChain State of AI 2024 Report.
Also in December an MIT study reports that some language reward models exhibit political bias:
Research from the MIT Center for Constructive Communication finds this effect occurs even when reward models are trained on factual data.
Many groups are researching different ways of using deep learning to interpret human brain signals, cf., recreate Pink Floyd from brain activity and read your thoughts. Here is a TED presentation on the mind-reading potential of AI.
Until today, I proof read my blog post text myself and then used Word for spell checking. A very manual process performed by me, a human being.
Today, for the first time, I asked an LLM to spell check instead. It is interesting to try out.
Here is a summary of our conversation:
I am still experimenting with how far to trust these things and how to remain critical, patient and persevere to obtain good results. If you have not tried using an LLM for your own purposes, I strongly suggest you give it a try and gather some experience.