Grasshopper

algorithmic modeling for Rhino

Hi All,

I have been googling all morning and have not found anything on what I am looking for.

I am really interested in creating an 'interactive' model - i.e. if you select an object in Rhino Space, it triggers a grasshopper definition and performs an action (I.e. drawing a graph in the model space, only while the object is selected).

Has anyone looked into this at all?

Regards

Lyndon

Views: 1538

Replies to This Discussion

It is possible since there are events associated with selecting and unselecting rhino objects. Grasshopper just doesn't listen to these events. You should be able to trigger gh solutions though via a script component. I can try later when I'm at my desk.

It works, but it's not pretty code and I'm not (ever) removing the handlers, so when the Grasshopper document which contains this C# component goes away it will be kept in memory until Rhino shuts down.

Attachments:

David,

This is fantastic, thank you. 

When you say when the grasshopper code 'goes away' it will be kept in memory - are you saying the objects created will remain in memory - or the code remains in memory?

What I am keen to do is select 'instruments' in a Dam 3D model (water level instruments etc) then, depending on the instrument, when it is selected, read the correct data column out of excel.

I think i can use your definition, then use the object ID's from Rhino with if statements to to return the correct data sets. Is it easy to retrieve the Rhino object ID though the C# script?

Cheers

LJ

Yeah just plug the geometry into a Guid parameter.

Thecode contains event handlers to selection events in Rhino, it also contains references to the grasshopper document the code is in. These references will prevent the document from being 'released' by the garbage collector, so they'll stick around in memory until the appdomain (Rhino) as a whole goes away.

I can add more code which cleans up if that's a problem. I can also add a small delay so that successive events aren't handled individually. And it's possible to limit the updates to specific geometry types and specific rhino documents. Just takes more code...

Hi David,

Im not sure if that would be a problem or not, best thing for me to do will be to get the definition working on on of my models - and ill see how it works. Once I have something working I can upload something for comment? Should give you some context on the project.

Have tried the GUID component. Only problem i have run into is i tried to feed this into a VB If statement and am getting errors. 

If x = 32a6738d-65de-44fd-aa4a-53842af54c38 Then
A = 1
End If

1. Error (BC30205): End of statement expected. (line 83)

Tried to convert to a string and got an error that GUID cannot convert...

Can you advise on how I can correct the above?

Cheers

Lyndon 

All sorted, put it through a parameter viewer first - then it works (I figured this out trying to show a colleague the error i was getting!)

Cheers.

This is not valid VB code:

If x = 32a6738d-65de-44fd-aa4a-53842af54c38 Then

Guids cannot be written like that, you'll have to actually do something like New Guid("32a6738d-65de-44fd-aa4a-53842af54c38").

This worked, Thanks David.

I have done a simple 'proof of concept' only, by creating 4 objects and using their (X,Y) locations to select which data to graph out of excel. As you click on each object, a different graph is displayed.

I need to write a def. to do an X-Y scatter plot - so once I have got that together will post the example for others reference.

If you know code for C# that would retrieve the object ID that would be excellent, as it would be a much more robust solution.

Cheers

Lyndon

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service