Grasshopper

algorithmic modeling for Rhino

Hi All,


I'm developing a custom component that has one input and one output. I've added a couple of options to the menu items list (when you right click on the center of the component). Here I expose some options to the user. The values that are chosen get stored as class variables. When the user closes rhino (and gh), and reopens rhino (and gh), the variables have reset themselves. I want the values to be able to carry over from when the user closes rhino / gh to when the user reopens the file.

Not quite sure what I'm doing wrong. I've attached the vb file as well as a sample gh file. 

Any help is greatly appreciated. 

Views: 571

Attachments:

Replies to This Discussion

Your properties shouldn't be Shared, because then every single component will have the same ones. You'll probably want to be able to specify different values for different components (in different files).

In order to retain your properties through a Save/Open cycle, you need to include them in the GH file. For this you must overwrite both the Write and the Read methods on the component class (be sure to call the base class methods!) and include your specific values.

That worked perfectly!! 

If I've stored a string when the file is closed/saved; when I'm reading the data back from the reader, what is the best practice, should I use:

OutputMessage = reader.FindItem("OutputMessage").InternalData

or

OutputMessage =  reader.FindItem("OutputMessage")._string

Best,

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service