Branches and text data in Grasshopper

Hey! I have a few questions about the use speckle for grasshopper:

  1. How easy is it to create new branches in Grasshopper?
  2. I would like to create expanded text notes to describe a project in Grasshopper. Is this the Globals section in the online view? How add data from the Grasshopper in this?
1 Like

Hi @Monfed!

We don’t really recommend creating branches from GH, as it can lead to weird things happening when you incorrectly wire things up in Grasshopper (which is bound to happen at some point)

That being said, I think you’ve already discovered this thread Creating branches from Grasshopper - #8 by RickTitulaer where Matteo shared a quick script to do this programmatically.

I’ll try to share the gh file on that thread today; but we also have instructions on how to setup the script nodes

As for the globals, it’s just another branch so you can send stuff from Gh using a url like

Hope that helps!

1 Like

Can you get some example on how to create globals from a Grasshopper? I don’t understand how to send text data


I think all you need to do is create a custom speckle object and send it to the globals branch:

cc @AlanRynne

It’s ok… I don’t understand how make this

Hey @Monfed, I just realised I wrote this message and never sent it!

globals branch needs to exist prior to sending from GH, so you need to go to the stream URL and created

Once that’s done, you can send to globals just like any other branch:

That being said, the globals viewer in the frontend is not really prepared to deal with the specific data structures of any given application (Grasshopper DataTrees in this case), so you won’t be able to view that data in the web editor properly yet, as it was designed to edit simple structures where properties have a single value (not a list).

It will though, be available to be received anywhere else (including back in GH).

As for your last question, just use the globals url as in the images :slight_smile: Just copy pasted it from my browser


Thank you for the explanation! Because it wasn’t showing in the web I thought I did something wrong, but it makes perfect sense that the globals viewer isn’t prepared for such objects.
Updating the globals viewer to handle such objects (is this on the roadmap?) maybe relates to this use case: Speckle Type Editor

1 Like

You’re welcome! I’ll take that as a hint that this should be documented somewhere more explicitly… :thinking:

In theory, the globals branch is just like any other, so nothing prevents you from programatically sending data there. But it was designed to be a specific place to hold simple metadata properties that would affect all branches, and hence had no default place to live inside the Speckle server.

That being said, I think we may need to open a discussion on what next steps to take here, as I don’t recall us having any particular short-term plans of improving this, but it seems like you are using it in much more complex ways that we imagined! (the team can correct me if I’m wrong :wink: )


I find mistake… I add /branches/ in this link

And last moment, how to make a text from sending objects ?

That’s the thing I was mentioning here:

You can send any type of data to the globals branch, but you can’t have it both ways (at least as it currently stands), as it was really intended as a place to add simple data manually. When you send data from any connector, it has a particular data structure that is not compatible with the globals viewer/editor.

We’re talking about some changes in the GH sender that could ease this limitation, but it’s still going to be there.

That being said, if you’re not afraid of a short script, we provide utility methods for send/receive operations that you could use to customize the way you send data: (6.7 KB)

it’s fairly similar to the create new branch script. Here’s the main function:

  private void RunScript(bool enable, string streamUrl, object speckleObject, ref object A)
    if(!enable) return;
    if(!(speckleObject is Speckle.Core.Models.Base)) throw new Exception("Input is not a Speckle object");
    var sw = new Speckle.Core.Credentials.StreamWrapper(streamUrl);

    try {
      var t = Task.Run(async () =>
        var acc = sw.GetAccount().Result;
        var client = new Speckle.Core.Api.Client(acc);
        var b = speckleObject as Speckle.Core.Models.Base;
        var commitId = Speckle.Core.Api.Helpers.Send(streamUrl, b, "Sent from custom script!", "Grasshopper", 0, acc, true, null, null).Result;
        return sw.ServerUrl + "/streams/" + sw.StreamId + "/commits/" + commitId;
      A = t.Result;
    } catch(Exception e){
      throw e;

And the result in the Speckle viewer.

The main thing to take into account is that you can only send a single speckle object to the Globals branch, and that object must:

  • Have all properties with values that are either simple types (text, number…) or a Speckle object.
  • Have all properties as not-detached (notice the lack of @) in the Create Speckle Object input.

If you plug in more than 1 object, it will send as many times as objects (this can be prevented too… but I just did “quick and dirty” example.


2 posts were split to a new topic: Get Branch URLs from Stream

2 posts were split to a new topic: Problem Sending to a Branch from Grasshopper: 401 (Unauthorized)

A post was merged into an existing topic: Problem Sending to a Branch from Grasshopper: 401 (Unauthorized)