Hey! I have a few questions about the use speckle for grasshopper:
How easy is it to create new branches in Grasshopper?
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?
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, 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).
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
You’re welcome! I’ll take that as a hint that this should be documented somewhere more explicitly…
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 )
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:
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){
Print(e.ToString());
throw e;
}
}