The Revit API discussion forum is pretty calm, and I dabbled further with LLMs and prompt optimisation:
Andrzej andrzej_m Matuszek proposes a solution to the long-standing issue on how to create dimension to wall centerline, center of core, faces of core, saying:
As far as I investigated, there is a rule that determines how indexed references that can be used for stable representation voodoo to create alignments are ordered.
For a multi-layer wall, I think the order is:
Here, N is the count of wall layers.
In the long-standing discussion, I would like to add that when we change the wall instance type, already created references have to remain unchanged and probably new references are appended.
There is no guarantee that we will reference to proper face using manually created stable representations, unless we've just created the wall ourselves.
Here is Andrzej's code using stable representation voodoo to create alignment to wall core center axis:
void CreateWallCoreAxisToGridAlignment(
Grid newGrid,
Wall wall)
{
var layersCount = wall.WallType.GetCompoundStructure()
.GetLayers().Count();
try
{
var stableRep = CreateStableRepresentation(wall, layersCount);
var ref0 = Reference.ParseFromStableRepresentation(Doc, stableRep);
Doc.Create.NewAlignment(View, newGrid.Curve.Reference, ref0);
Debug.WriteLine("NewAlignment to standard stable representation created!");
}
catch (Exception ex)
{
var stableRefs = GetStableRepresentations(wall, layersCount + 7);
foreach (var stRefStr in stableRefs)
{
try
{
var stRef = Reference.ParseFromStableRepresentation(Doc, stRefStr);
if (stRef != null)
{
Doc.Create.NewAlignment(View, newGrid.Curve.Reference, stRef);
Debug.WriteLine("NewAlignment to random stable representation created!!!");
break;
}
}
catch (Exception) { }
}
}
}
internal static string CreateStableRepresentation(
Element element,
int stRefIndex)
{
string uniqueID = element.UniqueId;
return $"{uniqueID}:{stRefIndex}:SURFACE";
}
internal static List<string> GetStableRepresentations(
Element element,
int count)
{
var result = new List<string>();
string uniqueID = element.UniqueId;
for (int i = 0; i < count; i++)
{
result.Add($"{uniqueID}:{i}:SURFACE");
}
return result;
}
Many thanks to Andrzej for sharing this.
Personally, I continue my quest of making good use of LLMs to help answer Revit API discussion forum threads. I recently mentioned my impending retirement, my Revit API support prompt, and the Promptimal prompt optimiser.
I installed and tested Promptimal locally and asked it to improve the prompt I was using previously. This is the prompt I started out with:
Promptimal reads the original prompt and asks you in which way you would like it improved. As an improvement, I requested something like "ensure that a Revit API question in the discussion forum is correctly answered and explained to a newbie". Promptimal generates the improvement in an iterative process, in five steps, and calculates a score for the quality in each step. In my first run, the scores on iterations 0 (original) to 5 were: 58 63 67 67 68 70, with the following end result:
Small changes, but apparently significant. Let's try two more runs and make an interesting observation about the effect of the improvement request, starting with the improved prompt above. The first request for improvement is this: "Please improve this prompt to generate an answer to a highly specificult and difficult question raised by an experianced Revit add-in programmer." Note that it includes two typos!
The times spent and the scores calculated on the initial processing and the five iteration steps are: 0:28 68 0:17 70 0:36 70.4 0:33 72 0:27 74.4 0:25 74.4.
The improved prompt in this case is:
After discovering and correcting the two typos, I ran the same process again. The corrected improvement request is "Please improve this prompt to generate an answer to a highly specific and difficult question raised by an experienced Revit add-in programmer." The scores change significantly, the computation time is reduced, and the result is surprisingly different:
Obviously every run of an LLM can generate a different result. However, it seems to me that it is still worthwhile to avoid spelling errors up front whenever you can.
Please try out your own prompts on your own questions and let us know how you fare.
Another surprising utility that might even come in handy populating your BIM with 3D objects is the functionality to generate 3D mesh model from a single photo provided by the SPAR3D stable point-aware reconstruction of 3D objects from single images.
I tried it out myself by creating a snapshot of a simple bookshelf and pasting that in. For such a task, the result was perfect. I was tempted to add trivial, but in fact, it is not trivial at all!