Hi-
As you can see from my posted graph, I have plenty of workarounds for this “issue”, but I’m really trying to understand why this doesn’t work when it seems like it should.
I’m using Revit 2016 and Dynamo 1.3.2.
-I have a bunch of Revit elements (selected, in this case, using Springs.Collector.CurrentSelection, but how you get the list of elements doesn’t seem to matter).
-I am trying to filter the elements by Revit category, using FilterByBoolMask. (I know that I can use custom nodes, such as Springs.Filter.ByCategoryName- but I’d like to do this using out of the box nodes for simplicity of distribution to others)
-I use Element.GetCategory to get a list of Categories for the selected elements.
-I use the Categories node to choose the Category I want to filter by. (Grids, in this case)
I assume that both these nodes return a Revit element, and that Revit Element is a Category.
If you feed the results of these nodes both through an Element.ID node, that seems to be borne out. (See the attached image)
So, if you feed the output of the “Category” and “Element.GetCategory” nodes into an “==” or “Equals” node, why does this fail to return “True”?
What am I missing here? Any insight is appreciated.
Thanks,
Joe
Not sure why this behaves like this, but here is the method I’ve always used, in a code block:
a.GetCategory.Name==b.Name;
1 Like
So much simpler! Thanks Jacob!
Edit: Of course, the “Name” method returns a string, so this is similar (though much more concise) than my using the “StringFromObject” Node…
However, the mystery continues…
1 Like
Apparently code blocks and node == don’t work with categories, not even with the same input.
List.Equals instead seems to work, at least in this case:
1 Like
I didn’t even think of using “List.Equals”. Thanks for the suggestion!
EDIT: What version of Dynamo/Revit are you using? “List.Equals” doesn’t come up as an option when I’m searching for Nodes. Is this from a package?
It is more surprising to me that simply “equals” doesn’t work- since, in the description, it’s talking about “object instances”.
However, if I wire the output of the Element.GetCategory node to both inputs of “Equals” (as you do in your example), it returns a single “true” value. Then I thought maybe it had something to do with "“List@Level”, and maybe messing around with those settings for the “Equals” node would help- but I tried that, and no joy. Also, that is not required when (for example) comparing unequal lists of Strings using the “Equals” node:
Joe
I think List.Equals is the Dynamo 2.0 version of Equals, so if you update Dynamo it should work as you expect
Thanks for the clarification. Unfortunately, I need to keep this backwards compatible to Revit 2016- At least for now.
Joe