Refreshing graphics, exchanging data, setting the start view, and random titbits related to AI, politics and climate:
In an internal discussion on refreshing spot elevation graphics after modifying its prefix, Dimitar Venkov pointed out
the UIDocument
UpdateAllOpenViews
method.
It forces a redraw, which may be one step higher than a refresh.
Refresh triggers a redraw only if a change is detected and may failing to detect some changes.
UpdateAllOpenViews
was introduced in Revit 2018 to force
a view update for DirectContext3D.
It sounds really powerful:
Updates all open views in this document after elements have been changed, deleted, selected or de-selected. Graphics in the views are fully redrawn regardless of which elements have changed. This function should only rarely be needed, but might be required when working with graphics drawn from outside of Revit's transactions and elements, for example, when using DirectContext3D.
This function is potentially expensive as many views may be updated at once, including regeneration of view's geometry and redisplay of graphics. Thus for most situations it is recommended that API applications rely on the Revit application framework to update views more deliberately.
Well worth taking a look at!
Unfortunately, there is no silver bullet for all graphics refresh cases, and the need to regenerate comes in many different flavours. For this issue, a different and simpler solution was required:
Question: How can I make Revit refresh spot elevation prefix automatically?
My code adds a plus-minus ±
sign to the spot elevation tag "prefix" in batches.
However, nothing changes in the view unless you refresh each tag.
I call both RefreshActiveView
and Regenerate
to no avail.
Answer: Try calling UpdateAllOpenViews
.
Response: I tried UpdateAllOpenViews
but failed.
However, I found a way to update the tag by changing the view scale manually.
Is there any method to do the similar thing through API?
Answer: You can change the view scale with the Scale
property, but I'm not sure that will help here.
I don't know of any other API call that would force the view to redraw, sorry.
Maybe you can retrieve
the UIView of
the active view, close it and then re-open it with the uidoc.ActiveView
property.
It's pretty extreme, but if nothing else works...
Response: I found a solution: just select all the tags as the selected annotation elements; after this operation, all the tags will update. Here is a code snippet:
ts.Start();
foreach (SpotDimension item in spotdimensionList)
{
Parameter para = item.get_Parameter(BuiltInParameter.SPOT_ELEV_DISPLAY_ELEVAT...
if (para.AsInteger() == 3)
MixResetter (item, spotdimensionTypeCollector);
else
DefaultResetter (item, spotdimensionIypeCollector);
doc.Regenerate();
uidoc.Selection.SetElementIds(new List<ElementId> ( item. id ));
}
//doc.ActiveView.Scale = 100;
ts.Commit();
//uidoc.UpdateAl10penViews();
The highlighted code is the final solution used to resolve the issue.
Many thanks to Shen Wang for sharing this!
Many add-ins exchange Revit data with Microsoft Excel spreadsheets. The SDK has two samples which do import/export from Excel spreadsheets, FireRating and ArchSample. They rely on a very old DLL which isn't playing nicely with .NET Core. If the Revit to Excel workflow is high value, it might be worthwhile modernising. If it is low value, export to CSV or some other easily supported document type may do the trick.
The 3rd most downloaded add-in in the AppStore is an Import/Export Excel tool using EPPlus, and that exchange with Excel is an important part of many other popular add-ins.
Here is a modern way to Open a spreadsheet document for read-only access.
You can also use a COM library that works so long as you have Excel installed on your computer.
By the way, for the sake of completeness, I implemented a multi-project cloud-based NoSql version of the FireRating SDK sample using the Revit Element UniqueId
and MongoDB instead of element id and Excel in FireRatingCloud.
Adrian Crisan of Studio A International, LLC shared a solution using the StartingViewSettings class for defining the start view using Revit API:
Question: Is it possible to define the start view using the API? Similar to the UI functionality for specify the starting view for a model. At the moment, I can only find a way to access the parameter and find out if a view is defined as the start view. Thanks :-)
Answer: Use this method to set your starting view:
void SetStartingView ()
{
// Code provided courtesy of:
// Studio A International, LLC
// http://www.studio-a-int.com
// The below code set the Starting View to a specific view that exists in Active Project
FilteredElementCollector feCollector = new FilteredElementCollector(activeDoc);
var myView = feCollector
.OfClass(typeof(Autodesk.Revit.DB.View)).Cast<Autodesk.Revit.DB.View>()
.Where<Autodesk.Revit.DB.View>(v
=> ViewType.ThreeD == v.ViewType
&& v.IsTemplate == false
&& v.Name == "my3DStartingView")
.ToList()
.FirstOrDefault();
FilteredElementCollector svsCollector = new FilteredElementCollector(activeDoc);
Autodesk.Revit.DB.StartingViewSettings svs = svsCollector
.OfClass(typeof(StartingViewSettings))
.Cast<Autodesk.Revit.DB.StartingViewSettings>()
.ToList()
.FirstOrDefault();
if (myView is object)
{
ElementId myViewId = new ElementId(Convert.ToInt32((myView.Id.ToString())));
if (svs.IsAcceptableStartingView(myViewId))
{
using (Transaction t = new Transaction(activeDoc))
{
t.Start("Set Starting View");
svs.ViewId = myViewId;
t.Commit();
}
}
}
}
Response: It works perfectly! Thanks a lot!
People are really bad at understanding just how big LLM's actually are. I think this is partly why they belittle them as 'just' next-word predictors. Check out the explanation by @jam3scampbell, leading to the Searle Chinese Room Slow Motion Intelligence thought experiment.
Reading Little Brother by Cory Doctorow led me to check out the base rate fallacy or false positive paradox that we have been seeing more and more of – and suffering the consequences of – in real life in recent years.
Talking about suffering the consequences, the period from February 2023 to January 2024 reached 1.52C of warming compared with pre-industrial levels So, we have already achieved the world's first year-long breach of the key 1.5C warming limit. The calendar year was one month earlier, and 2023 was confirmed as world's hottest year on record.
To put that into perspective, xkcd published a timeline of earth's average temperature since the last ice age glaciation to demonstrate
when people say, "the climate has changed before", these are the kinds of changes they're talking about.
Global warming is a joke – Even the Antarctic ice sheets are cracking up
Are you thinking about installing PV? I am. Now is a good time for buying PV panels, cf. the price trending down below 13 cents per Watt, the lowest price ever. Will the trend continue? How fast can it turn around?