Design Script - Categories equal

Hi everyone,

Just saw this post on LinkedIn (Would like to tag the creator but can’t find his account on the Dynamo forum) and wanted to post it here so it may be more insightful.

Suppose you try to compare two categories as Revit.Element.Category types on the canvas, you get only false results.

But if you do it with python code (don’t judge :smiley: ), it works well in both string and Element.Category type.

Am I missing something here or is it just a bug?

Kind regards.

It’s not really a bug, it’s just that Dynamo and DesignScript allow for different object comparisons than Python and the API. Dynamo tends to stick to more basic object type comparisons only. If I had to guess, I’d say it’s because of the wrapper.

1 Like

Could you show the data which is flowing through your nodes in the first screenshot?

Also, using the ID of the category instead of the name would probably be better

4 Likes

Thank you for the explanations.

The data in the first screenshot is not available to me, as mentioned it’s from LinkedIn.
So I recreate the issue and you can see it in the image shown at the bottom.

I know John Pierson talked about the ID being more reliable for script upgradability to future versions, but you are saying it is also more reliable to do comparisons with the ID instead of the name of the category.

Thank you one more time,
Kind regards.

Both are pretty reliable. Of course we can’t promise that a category name or Id will never change, but that’s very rare. If you deal with multiple languages then Id is definitely better. Otherwise it’s basically down to preference.

1 Like