Grasshopper

algorithmic modeling for Rhino

Hello everybody,

 

I am wondering if there is a way of calling, from a a script component, a function wrote in another different script component.

 

It would be great!

 

Cheers!

Views: 1943

Replies to This Discussion

This is not possible. At present, you'd have to put these functions in a dll that you reference from both components. It would probably be a nice idea to be able to include source code files in scripts.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Ok, David.

 

And yes, it would be very nice!

:-)

Hello David,

Is there a way to reference a dll into the C# or VB Grasshopper scriptable component ?

 

In the menu of VB and C# components you'll find a Referenced Assemblies... item. It allows you to add a dll.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

really great ! thx

Hi Miguel,

 

it actually depends. It is not a Grasshopper feature, but there are cases in which it is possible to call functions from other components. The easiest is in Python. You can easily pass function references and callable items to other components and call them from there.

Here is what it would look like:

x() in the middle calls the x function, that returns the text you can see at the end of the definition.

 

Besides that, this type of operation is also possible in C# and Vb.Net, with a language construct that is called delegate. A delegate encapsulates a reference to a function. However, because delegates are type safe, they are a little more complicated to use. There is an example in the same file in C# and Vb.Net.

To see the Python components, you will need the last version from here.

I hope it helps,

- Giulio
_____________
giulio@mcneel.com
McNeel Europe

Attachments:

Hello,

 

I am trying to make a mathematical function and call it into another python component.

Here is the file, maybe it is possible somehow.

 

Best regards

Attachments:

Hi Stefan,

sure it's possible.

Here you go.

I hope this helps,

- Giulio
________________
giulio@mcneel.com
McNeel Europe

Attachments:

Thank you Giulio, from now on my work will go smoother.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service