Hey @Community,
we’re back with a minor announcement for our Grasshopper connectors:
The way we handle DataTree’s in grasshopper is about to change:
Let me explain…
Current behaviour
Up until now, we’ve been converting Grasshopper DataTrees into nested lists, which has been working fine but has some unwanted side-effects in order so fully support Gh->Gh interop.
Mainly, in order to preserve branch indices, we’ve been adding empty placeholder lists whenever necessary. This lead to situations were sending a single point will create many unwanted nested lists before you could get to your data.
This would force your data to be nested it at least 2 lists (one for the data tree, another for the branch) in its simplest form.
New behaviour
Now, we’re changing the way we convert DataTree’s. Instead of becoming nested lists, they will now become Base
objects who’s key’s are the DataTree’s branch paths.
This is, in reality, how Grasshopper internally works. A DataTree is just a dictionary where every Path contains a list of objects.
This simplifies the way you treat and deal with Grasshopper data:
- DataTree’s are now easier to view and explore. No more deeply nested lists.
- Have some ugly DataTree structures? we’re not here to judge! They’ll now be represented more accurately than before in cases where branches of different levels are mixed (i.e.
{0;0}
and{0;0;0}
(these were already supported, but lead to index shifting in some cases and loss of data).
What does this mean for you, the average speckler?
Nothing really, if you’re using our connectors to send and receive your Speckle data everything should work exactly as it did before.
The only difference you’ll notice is that now the Grasshopper data is easier to navigate in our web application, and the increased support for unconventional data structures.
What does this mean for developers?
If you’ve developed your own connector, or have scripts or plugins that processed Grasshopper commits, you should check that they are capable of:
- Consuming pre-existing commits that had nested lists
- Consuming the new
Base
object with paths as keys.
The new case can be handled just like any other Base
object. GetDynamicMembers
will give you the names of all the paths, and the values will always be List<object>
.
What if i depend on/need the nested list structure?
Right now, we haven’t exposed a way to convert these Base
objects representing DataTrees into nested lists, although it does exist within our codebase.
If you feel the need for this, or anything else…
We’d love to hear from you!!
If you got this far down, you must have an opinion about all these changes, and we’d love to hear about it! Is this what you’ve always been waiting for? Will this break your entire universe?
We’d definitely want to avoid having angry Specklers with pitchforks at out doorstep! Now its your time to let us know, and help us shape Speckle in the process!