Grasshopper

algorithmic modeling for Rhino

I have several exe I'm considering to "encapsulate" into several Grasshopper components. Thanks to System.Diagnostic, I'm quite successful so far. I'm using a GenericParam to export the StdOut and StdErr. With a C# script I was able to read them (a System.Object that is casted into a StreamReader) and export them into a list of string.

So far so good, but now I'm struggling on coding a component that does exactly what I'm doing with the script. I've tried to use a GenericParam but I have issue with the cast. 

At that point, I imagine I have two choices: 

  a) create a new parameters (I imagine I have to use GH_GOO<StreamReader>)

  b) figure out how to cast the GenereicParam

but I understand the solution a) is the right way to do in Grasshopper.

Question: Has anyone already written this parameter and can share it with me? Is there any other examples than the one in the SDK to see how to create a parameter?

Thank you

Serge

Views: 531

Replies to This Discussion

Hi Serge,

there are basically two reasons to write your own parameter (i.e., something which either implements IGH_Param, or, better yet, derives from GH_Param<T>, GH_PersistentParam<T>).

  1. You want to provide a dedicated parameter for your own data type.
  2. You want to extend on the functionality of an existing data type.

Your own data-type is a class which implements IGH_Goo (or derives from GH_Goo<T>). It could technically be anything, though wrapping a StreamReader seems like a very odd choice. 

Are you looking to create a data-type or a parameter? If the latter, do you already have a data-type or are you looking to provide new functionality for an existing type?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David,

I want to encapsulate the EXE. So I have the stdIn in the inputs and stdOut + stdErr for the outputs. And I want to cascade the component (i.e. pipe the EXEs).

So the data type does exist, it's a Stream (StreamReader for stdOut and stdErr; StreamWriter for stdIn). I just want to pass them. If I understand well it means that I'm looking to create a parameter.

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