Grasshopper

algorithmic modeling for Rhino

Good morning,

I am trying to create a Value List (Grasshopper.Kernel.Special.GH_ValueList) with default items that are different from the ones in the Value List component.

Creating this via  a user object is very straighforward and easy. Though, I would like to incorporate such a component in a GHA assembly.

My initial approach is to subclass GH_ValueList. The trouble is that the list of items for GH_ValueList is a private class attribute and it cannot be accessed from a subclass.

Is this restriction intentional? Is there any plan to modify this? Or am I completely missing the right way to create a Value List with different default items.

Regards,

Guillaume Florent

Views: 951

Replies to This Discussion

Hi Guillaume,

Most of my custom objects were not designed to be subclassed. GH_ValueList does have a public property that allows you to add/remove items to the list of constants. ListItems simply returns that private list. You can access this property whether you've subclassed the value list or whether you're trying to modify an existing value list.

--

David Rutten

david@mcneel.com

Tirol, Austria

Hi David,

Thanks very much for your answer.

So, from what I understand, the list of items in a GH_ValueList instance can modified (that's what we do when we replace the values in the Dialog) but the values that appear in the GH_ValueList Component just after it has been dragged to the canvas cannot be changed unless a "MyOwnValueList" is developped very similar to GH_ValueList (since the initial values are hardcoded in the constructor of GH_ValueList).

Correct?

By the way, thanks for bringing GH to all of us. It is one of the greatest pieces of software I ever came across.

Have a nice day,

Guillaume Florent

David,

Is there an example of this code somewhere that I can have a look at? I am currently trying to implement something similar and it would be nice to have a starting point. 

Cheers! 

I don't think so. You can always try and disassemble Grasshopper.dll and look at the source. I hereby grant you permission to do so for GH_ValueList.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service