mcneel / ghpython

A Grasshopper component for Rhino.Python
http://www.food4rhino.com/project/ghpython
117 stars 34 forks source link

Question: Call a function from within ghPython component from C# components #74

Closed antonszilasi closed 7 years ago

antonszilasi commented 7 years ago

@piac @sbaer

I have a ghPython component which contains a function, from within my C# components I would like to be able get this ghPython component from the document and call the function within the ghPython component.

Is this possible? If so could you please provide me with some sample code to do so?

Many thanks!

piac commented 7 years ago

Hi @antonszilasi

sorry for the delay in getting back to you. Most of the questions get faster answers on discourse these days. It is possible to create a System.Delegate of type Func<object,object> (or other more precise types) and assign it to the output of the GhPython component. This method will work in Rhino 5 and in Rhino WIP.

capture

pass-functions.zip

I hope this helps,

Giulio

-- Giulio Piacentino for Robert McNeel & Associates giulio@mcneel.com