Grasshopper

algorithmic modeling for Rhino

Programmatically connecting a grasshopper parameter to a Rhino Geometry point

Hello all,

I want to connect a Point Parameter in my Grasshopper document to a Rhino point or Geometry. This would be the equivalent of selecting the following items from the menu:

"Select One Point" / "Select Multiple Points"

... and then dragging over a point in Grasshopper.

I need to do this programmatically, preferably using C#.

I tried the following:

point = Rhino.RhinoDoc.ActiveDoc.Objects.Find (<rhino-point-guid>)

Grasshopper.AssignDataToParameter(<gh_instance_guid>, point)

But that doesn't work. Any idea on how to achieve this?

Thanks in advance,

Milan

Views: 575

Replies to This Discussion

This is difficult in a C# component because you're not supposed to modify a parameter/component during a solution. That's why I have to schedule a solution and provide a callback. If you're doing this as a response to a UI event (like a menu-item-click or something) then you can just modify the PersistentData directly.

Do note that if you're doing it from a UI event, then you need to eventually call param.ExpireSolution(true) instead of param.ExpireSolution(false). It's false in this case because a new solution is already happening anyway (it was scheduled after all).

Attachments:

Thanks David that works as expected.

Our use case is a bit simpler as we don't need live updates.

We just want to automate the loading of documents and connect all the variables. Once everything is setup, we can run the solution and make use of the output.

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service