Grasshopper

algorithmic modeling for Rhino

I can compare two lists using firstList.SequenceEqual(secondList), which could return a true or false. SequenceEqual determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.

How do I compare two DataTrees, a Grasshopper construct, the same way SequenceEqual() does with Lists?

Views: 234

Replies to This Discussion

You might not be able to, depending on what data is stored inside the datatree. There is no good equality test for Curves and Breps and Meshes. However if the instances are the same (as opposed to two breps that just happen to look the same), then you can use the equality operator.

DataTrees have a property called TopologyDiscription which returns a string that you can use to compare paths and lists lengths. But if you also want to test to see if the lists store the same values, then you'll have to iterate over them and use SequenceEqual or some other equality test.

--

David Rutten

david@mcneel.com

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service