"Saving" custom component input from windows form


(Merijn) #1

Hi All,

I recently made a set of components in which I used windows forms to have the user select a project folder and certain keys. Now, everything works fine in grasshopper, however, when the script is saved, it does not save the selected input of the user.

This means that everytime the grasshopper-script will be re-opened, the project folder and all the keys need to be selected all over again.

So my question is: Is there a way to save the input, generated by a windows form?

The components are made in C# by the way.

Kind regards,

Merijn


(Giulio Piacentino) #2

Probably the easiest way would be to save a file next to the .gh, maybe “localpreference.txt”, and save there the input.

Use RhinoDocument.FilePath or one of the methods outlined here:

should do.

Thanks,

Giulio


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


(C18957181678) #3

you can :

  1. rewrite read write method.
  2. use INI to store data.
  3. use REG to store data.
    when the grasshopper-script be re-opened, you obtain the data from INI or REG.

(Merijn) #4

Thanks, I’ve overridden the read and write methods and it works fine now!
I just store the selected keys in a string[] and everythings peachy!