InternalException from FilteredElementCollector in Revit 2023

InternalException from FilteredElementCollector in Revit 2023

bim.bot
Contributor Contributor
552 Views
5 Replies
Message 1 of 6

InternalException from FilteredElementCollector in Revit 2023

bim.bot
Contributor
Contributor

Hi All,

But I'm dealing with a bug in Revit 2023 where an internal exception is thrown when attempting to iterate a FilteredElementCollector.  The exception is only thrown under the following very specific conditions: ExternalApplication i.e. Revit 2023. 

 

Please find the code snippet FilteredElementCollector - 

 

 

 

// Set the category filter for the ebenelist
ElementMulticategoryFilter dbEbeneCategoryFilter = PosNumberEnter.GetCategoryFilter("EBENE");
List<string> ebeneList = GetEbeneList(doc, dbEbeneCategoryFilter);
if (ebeneList.Count > 0)
{
List<Color> ebeneGradient = CreateGradient(ebeneList.Count);
// Set the ebenefilterview
ViewFilters(doc, ebeneList, ebeneGradient, "Ebene");
}


catch (Exception ex)
{
// Trace
Trace.Indent();
Trace.WriteLine($"{MethodBase.GetCurrentMethod().DeclaringType.Name} {MethodBase.GetCurrentMethod().Name} Exception\n" +
$"trace: {ex.StackTrace}\n" +
$"message: {ex.Message}\n" +
$"data: {ex.Data.ToString()}\n" +
$"source:{ex.Source}\n" +
$"targetsite: {ex.TargetSite}\n" +
$"inner exception: {ex.InnerException}\n");
Trace.Unindent();
throw;
}

 

 

Please let me know if something is not clear. I look forward to hearing from you. Thank you!

0 Likes
553 Views
5 Replies
Replies (5)
Message 2 of 6

RPTHOMAS108
Mentor
Mentor

To get help you probably have to break it down into recognisable features of the API.

 

e.g. what does 'PosNumberEnter.GetCategoryFilter("EBENE")' do internally?

 

If you set out the minimum of what causes the issue then it will be easier to understand for those answering.

0 Likes
Message 3 of 6

mhannonQ65N2
Collaborator
Collaborator

The constructor FilterStringRule(FilterableValueProvider valueProvider, FilterStringRuleEvaluator evaluator, string ruleString, bool caseSensitive) was removed in Revit 2023 because the caseSensitive parameter didn't do anything. It was replaced with a constructer that does not have that parameter. You need to change your code to use the new constructor and compile it against the 2023 API dlls. There are plenty of resources on this forum about multi-targeting different Revit versions.

0 Likes
Message 4 of 6

bim.bot
Contributor
Contributor

@mhannonQ65N2  thank you for the response! If possible for you if would able to share a specific examples available on this forum regarding multi-targeting different Revit versions?

0 Likes
Message 5 of 6

bim.bot
Contributor
Contributor

@RPTHOMAS108 thank you for the response!  'PosNumberEnter.GetCategoryFilter("EBENE")'  does internally Match the structural element type to Revit built-in categories and creates a database filter. Please find the code below for more details-

 

 public static ElementMulticategoryFilter GetCategoryFilter(string typeName)
        {
            try
            {
                // Match the structural element type to revit builtin categories and create a database filter
                List<BuiltInCategory> categories = null;
                if (!(null == App._positionNumbering))
                {
                    categories = App._positionNumbering.MatchCategories(typeName);
                }
                else
                {
                    throw new ArgumentNullException($"Please instantiate the PositionNumbering class in the static App field.");
                }
                List<ElementId> categoryIds = new List<ElementId>();
                foreach (BuiltInCategory cat in categories)
                {
                    categoryIds.Add(new ElementId(cat));
                }
                ElementMulticategoryFilter dbCategoryFilter = new ElementMulticategoryFilter(categories);
                return dbCategoryFilter;
            }

 

0 Likes
Message 6 of 6

eason.kangEDLV4
Autodesk Support
Autodesk Support

Hi @bim.bot, we would like to help, but could you share the code in pure Revit API calls without your own wappers or extensions? It will help us understand the issue you addressed more easily. Thank you for your cooperation and understanding.

If possible, please follow this instruction to provide a Reproducible Test Case for investigations.

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b


Eason Kang
Developer Advocate
Developer Advocacy & Support Service
Autodesk Platform Service (formerly Forge)

0 Likes