Hi guys - this is my first question on this forum, so please be gentle. I’ve begun seriously attempting to learn Dynamo, and I think I’m finally making some headway, although I’ve got a LONG way to go. As part of the process, I sometimes will come up with a particular graph idea that has no real use in the real world, but allows me to explore certain logic / workflows. So I came up with one to explore the process of filtering a list using a boolean mask - get a list of all wall elements in the project, and get their wall types. Then compare the wall types to a specific wall type using the == operator. Those that match (“true”) go to one list, those that don’t (“false”) go to another list. Except I can’t the == operator to work right. I’m attaching an image of my graph - note that I am testing against the wall type “Generic - 8"” - and there are two walls that match that - except in the list resulting from the == node they all show as “false”. As a test I used the “List.GetItemAtIndex” node to pull out the first element in the list and when I wire that to the “x” input of the == operator, it returns “true”. Why isn’t it working when I run the list into the “x” input? I’m pulling my hair out by the roots here, and that’s bad, because there isn’t much left, and I find this is happening all too often lately… thanks in advance!
Solved! I had to add another node after both of my test conditions - “WallType.Name”. Now it works fine. But I don’t understand why… Type=Type or String=String - what’s the difference?
The == operator is to compare values, so that is why it works with WallType
.Name node since its outputs are strings. If you want to compare two objects, use the “Equals” node
Duly noted - thanks!
I am reliving the experience I had when I learned AutoLISP years (eons?) ago. I explained it to a co-worker like this: First you’re trying to learn a new language, which is in two parts, the vocabulary (functions) and the grammar (rules). And then you have to learn how to apply logic, because the way logic is applied in AutoLISP is not exactly the same as the way it might be applied in Dynamo.
Thanks again - Merry Christmas
The difference is in object you are passing from one node to the other.
All information that string contains is text. Wall type contains much more information like type comments, type mark or type name and these are stored as strings. Computers can only compare objects that are same type. So you can’t compare a string to a wall type, but you can call wall type name (string) and compare it to another string as you did.
Thats a good way to describe it! Happy Holidays!
Dynamo’s virtual machine is written in c#, a .net language, so it is useful to reference some of Microsoft’s documentation on these concepts.
strings and numbers are primitive types and so their comparisons are more straightforward - objects can have reference or value comparisons, - and value comparisons may only succeed if the author of that type has implemented sensible equality or hashcode methods.