# Categories vs. Category.ByName Discrepancy in 2.13

**URL:** <https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196>\
**Category:** Revit\
**Created:** [June 1, 2022, 8:06pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196 "2022-06-01T20:06:10Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpclark](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jpclark](https://forum.dynamobim.com/u/jpclark)\
**Post date:** [June 1, 2022, 8:06pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/1 "2022-06-01T20:06:10Z")

</div>

Hey there Dynamo community. I’m checking my company’s scripts to make sure they work in Revit 2023/Dynamo 2.13 and noticed this issue with specifying Categories using the Category.ByName node. Wondering if anyone has any insight on this.

We specify Categories using the ByName approach for simplicity, ability to be in a code block, etc. We’re trying to grab the four Categories in the code block, but you can see in the Category.ByName preview list that 0 & 2 are actually grabbing the "Analytical Surfaces - " Categories, not the plain ones that I’m wanting (as shown in the separate Categories nodes below). Any ideas on how to specify the plain “Ceilings” and “Roofs” Categories by name?

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/a/1a89536fe5cf379254e3e3adcadd9539c6a1a5ee.png)

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [June 1, 2022, 8:54pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/2 "2022-06-01T20:54:31Z")

</div>

Hello @jpclark - The bad news is that this is a regression that slipped through ☹ The good news is that this is a known issue that the team is working on 🙂

The node under the hood is here - [DynamoRevit/Category.cs at a90305ebc8fe2227d646760233a12f33ccc75046 · DynamoDS/DynamoRevit · GitHub](https://github.com/DynamoDS/DynamoRevit/blob/a90305ebc8fe2227d646760233a12f33ccc75046/src/Libraries/RevitNodes/Elements/Category.cs#L74) if you are curious to looking.

In the interim, I suggest you either use the `Category` dropdowns, or a Python `Filtered Element Collector`. Shoutout to @Konrad_K_Sobon for the base code that was modified below.

```auto
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import BuiltInCategory,ElementMulticategoryFilter,FilteredElementCollector

import System
from System import Array
from System.Collections.Generic import List

try:
    errorReport = None
    
    cat_list = [BuiltInCategory.OST_Rooms, BuiltInCategory.OST_Ceilings, BuiltInCategory.OST_Floors, BuiltInCategory.OST_Roofs, BuiltInCategory.OST_Stairs]
    typed_list = List[BuiltInCategory](cat_list)
    filter = ElementMulticategoryFilter(typed_list)
    output = FilteredElementCollector(doc).WherePasses(filter).ToElements()

except:
    # if error occurs anywhere in the process catch it
    import traceback
    errorReport = traceback.format_exc()

# Assign your output to the OUT variable
if None == errorReport:
    OUT = output
else:
    OUT = errorReport
```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/5979d8fd9e6802ec48789e9d44914df33ecbf642.png)

---

<div class="post-metadata">

**Author:** ![jpclark](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jpclark](https://forum.dynamobim.com/u/jpclark)\
**Post date:** [June 1, 2022, 8:58pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/3 "2022-06-01T20:58:05Z")

</div>

Thanks for the update and code, @solamour. Very much appreciated!

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 1, 2022, 9:11pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/4 "2022-06-01T21:11:40Z")

</div>

_Note: I haven’t tested this between documents a whole lot._ But, I believe category ids are reserved and stay standardized.

I would be pretty inclined to use this method rather than python.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/9/d9a548d1eba7c824a1563aace018a0c73df37317.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 1, 2022, 9:42pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/5 "2022-06-01T21:42:01Z")

</div>

Now that drop down’s are static in all supported Dynamo for Revit releases, I’m thinking migrating back to drop downs might be more stable overall; those IDs may change across Revit releases.

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 1, 2022, 9:45pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/6 "2022-06-01T21:45:20Z")

</div>

> [@jacob.small](#):
>
> those IDs may change across Revit releases

Dropdowns still change quite often or wipe out the selection ma dude. I think I trust Jeremy on this one.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/2/e2dd6b95fa9b1778961b35e5551c902cdad9f7dd.png)

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 1, 2022, 9:49pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/7 "2022-06-01T21:49:23Z")

</div>

Also, monocle update is incoming to help with this regression. I was using the ByName option too, but with this news, that’s a big ol nope.  
 ![20220601-categoryById](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f620e178544085044230655050f735e4756d4124.gif)

Id seems to be more stable across languages too:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/5/65823e7b87104498e2defb341655cadf4318d149.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 1, 2022, 10:34pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/8 "2022-06-01T22:34:03Z")

</div>

Annotation Crop Boundaries (-2000549 to -2000547), Crop Boundaries (-2000548 to -2000536), and View References (-2000198 to -2000197) have all had their id values changed at some point in the last 5 versions. Not popular categories for bulk selection, but worth knowing and a good case of “trust but verify,” because with systems of a certain complexity things will usually change at some point.

Personally since nothing is completely static drop downs may be best as they can be resolved by just about any user:

> “Oh no a warning. Here’s the first one and it’s the second node in the string. Proceeding node is a blank drop down, and is named “Walls.” Easy enough fix. Yay now it works.”

Admittedly not all users will make such a change, and the development team will continue to strive for better consistency. But we do have to make a choice for one of the 3 or 4 (5?) methods available here. Either way I am in favor of moving past ‘by name’ (for the language issues alone I disliked it before).

PS: Running a full report of the category names and id for Revit versions 2019 to 2023 after dinner; I’ll post here when done and will include the dyn used to mine the info for anyone who’s interested.

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 1, 2022, 10:52pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/9 "2022-06-01T22:52:21Z")

</div>

I think the categories you mentioned are duplicates and not changes…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/9/c97ac49de2d62117710f0293fb6a60d87535ad0b.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 1, 2022, 10:57pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/10 "2022-06-01T22:57:48Z")

</div>

Maybe? I can confirm differing values between 2019 and 2020. Moving .dyns and and results between systems to post now.

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 1, 2022, 10:57pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/11 "2022-06-01T22:57:52Z")

</div>

wait… that is a special category?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/e/8e0797532d14b1c5c9f0aee16a2e516a53dd24f8.png)

_okay, getting off topic now_, but that is interesting. **It didn’t change ids,** it is just displaying the same name in Dynamo’s dropdowns. (+1 for Dynamo dropdowns I guess? 🤣)

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 1, 2022, 10:59pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/12 "2022-06-01T22:59:46Z")

</div>

> [@jacob.small](#):
>
> Moving .dyns and and results between systems to post now.

I would say to post the full OST name then since Dynamo is truncating names for whatever reason resulting in inaccurate results.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/2/c2c8f63052fa8d63459ea003fc5f3fe68db8bb61.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 1, 2022, 11:02pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/13 "2022-06-01T23:02:30Z")

</div>

Good call… I’ve got another change to make for that reason… and one I can’t make between bites of dinner.

I’m going to ask someone on the Revit dev team about this on this because something is odd, and we can’t really do what’s best for the community if we don’t have all the info… Stay tuned for more. 🙂

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [June 2, 2022, 8:50am UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/14 "2022-06-02T08:50:18Z")

</div>

@jpclark have you tried using BuiltInCategory names with Category.ByName yet (e.g. OST\_Roofs)? That might still work in Revit 23 and also it‘s language neutral.

---

<div class="post-metadata">

**Author:** ![jpclark](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jpclark](https://forum.dynamobim.com/u/jpclark)\
**Post date:** [June 2, 2022, 1:05pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/15 "2022-06-02T13:05:59Z")

</div>

@Andreas_Dieckmann Using the BuiltInCategory names seems to work well, at least for the handful of categories I’m concerned with.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/1/617a6f8391610905a933ddfc404447f36de276db.png)

I’m thinking this is the workaround I’m going to use for now, since my scripts are all locked to specific Revit versions, and then see what develops as a result of all the other posts and ideas here for future best-practices.

Really appreciate all the dialog and ideas!

---

<div class="post-metadata">

**Author:** ![gina.liu](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@gina.liu](https://forum.dynamobim.com/u/gina.liu)\
**Post date:** [June 7, 2022, 1:15pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/16 "2022-06-07T13:15:12Z")

</div>

Hi @jpclark Does this issue happen on R2022 or an earlier version?  
I remember “Analytical Surfaces - xxx” categories were added into Revit years ago.

---

<div class="post-metadata">

**Author:** ![jpclark](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jpclark](https://forum.dynamobim.com/u/jpclark)\
**Post date:** [June 7, 2022, 5:32pm UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/17 "2022-06-07T17:32:38Z")

</div>

@gina.liu Not that I’ve ever seen. My organization has been supporting these same scripts with these code blocks since R18, and they’ve been fine till now.

---

<div class="post-metadata">

**Author:** ![minthu](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@minthu](https://forum.dynamobim.com/u/minthu)\
**Post date:** [May 10, 2024, 8:57am UTC](https://forum.dynamobim.com/t/categories-vs-category-byname-discrepancy-in-2-13/77196/18 "2024-05-10T08:57:28Z")

</div>

I created this custom node and it’s working well as a replacement of the original node “Category.ByName”.

 ![CategoryByName](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/4/b48840a7184845cc381e38821ce396788e635e1e.png)
