How to subscribe to an event that fires when new component is added to canvas?

unhandled

(Fari697) #1

Hey guys,

I’m in middle of grasshopper hackathon for 30 more hours :slight_smile:

I’m trying to create a grasshopper component using C# that when dragged to canvas subscribes to some event that from that moment on everytime user drags new component to canvas I can get the id/name and other stuff from that component that was just added.

Also if you know how to get a list of all the components in the canvas I would like to know that.

All the help is appreciated.

I’m using rhino5 and grasshopper 0.9.0.0.7.6

Thanks


#2

GrasshopperDocument.ObjectsAdded and GrasshopperDocument.Objects.


(Nathan 'jesterKing' Letwory) #3

Don’t forget to download the Grasshopper SDK doc file from the Grasshopper help menu.


(Tom) #4

sounds like a nice competition. :smirk: can you win something?

Just in addition: In case you „hack“ within a scriptcomponent instead of writing an own .gha. Be very careful with using events. On scripting level eventhandling can lead to very weird behaviour if you don‘t know what you are doing, because you cannot properly subscribe and unsubscribe.


(Fari697) #5

Hey,

No winning prizes here, just experience :slight_smile:

I got this to work, thanks for the help