Knowledge Graph - Send Data to GH from Rhino Command

I’m trying to mimic some of the functionality of Heptabase in Rhino/GH. Nothing in this particular definition ever gets baked to Rhino, I’m using GH purely for display.

Connecting the ‘cards’ is a pain since I have to:

  1. select two crvs
  2. click into the GH window
  3. right-click on crv component
  4. navigate to ‘manage curve collection’
  5. click ‘add crv’ and then select the crv (twice)
  6. close the window

Instead I’d like to run a custom command in Rhino that adds the two selected curves to a designated curve parameter in GH. I’d also like to have the inverse command that deletes two selected curves from the aformentioned curve list in GH.

I’m looking for some C# examples of how to pass data from a Rhino command to GH. The below answer is the closest I’ve found, but I was hoping for some actual code to examine since I’m very new to C#.

Have you considered using GeometryPipeline like this:

_-ChangeLayer _Pause "Selected"

_-ChangeLayer _Pause "Default"

Yes, I tried something similar to that with geometry pipeline. The problem is that the connections between cards require information about which two cards are connected (and I want the initial connections to be maintained when I add new connections). The only way I currently know to do this is to add them as pairs to a list (the same cards appear multiple times in this list), dispatch the list, and then filter from another list of all cards in the document by user attributes.

Your previous answer with the python script looks pretty close to what I was looking for though, thank you. I’ll see if I can translate that to C#.

Mahdiyar–I tried your python script and it does indeed do exactly what I want, so thanks!

The only issue I’m having is that AssignDataToParameter deletes all previous data in the parameter, instead of just adding the data to the existing list, which is the behavior I want. I don’t see AddDataToParameter (or something similar) as an option in the Grasshopper documentation.

Do you know if there’s another method I’m missing?

import rhinoscriptsyntax as rs
from Grasshopper import Instances, Kernel
from System import Guid
gh = rs.GetPlugInObject('Grasshopper')
param_id = Guid('2a9de3cc-633f-486f-b97f-e2e53c954952')
if gh.IsEditorLoaded():
    doc = Instances.ActiveCanvas.Document
    if doc:
        param = doc.FindObject(param_id, True)
        if param:
            ids = rs.GetObjects('Select curves', rs.filter.curve)
            for id in ids:
            param.ExpireSolution(True) (3.2 KB) (550 Bytes)

1 Like

Perfect, thank you!