Message 1 of 4

Not applicable
06-02-2021
07:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Like the title says, I am looking through all the elements and finding the shared parameter "AE Opmeting" in them. When they are null or blank I want to add a 0 to the parameter value.
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var app = commandData.Application;
var doc = app.ActiveUIDocument.Document;
var sortedElements
= new Dictionary<string, List<Element>>();
// Iterate over all elements, both symbols and
// model elements, and them in the dictionary.
ElementFilter f = new LogicalOrFilter(
new ElementIsElementTypeFilter(false),
new ElementIsElementTypeFilter(true));
var collector
= new FilteredElementCollector(doc)
.WherePasses(f);
string name;
foreach (var e in collector)
{
var parameter = e.LookupParameter("AE Opmeting");
// var Opmeting = parameter.AsInteger();
if (parameter == null) parameter.Set(0);
}
return Result.Succeeded;
}
I get the null exception, which sort of is expected.
https://www.revitapidocs.com/2022/fe10010f-e127-7248-1f17-8c1ee0d41ea0.htm
While reading about this, I do not know how to implement this.
If this is even the right change that has to be made.
Any help will be greatly appreciated.
Solved! Go to Solution.