Grasshopper

algorithmic modeling for Rhino

I want to add the text "graph one" to a datatree which I am outputting from a panel.

The code I am using to output this data is below.

load_Profileout.AddRange('Graph one',gh.Kernel.Data.GH_Path(0))

The issue as you can see is that I want graph one in element 0 of this list not spread over 8 elements like you can see in the picture below. 

How do I do this?

Views: 433

Replies to This Discussion

Hi Anton,

AddRange method requires a list of data for its first argument. So when you supplied your "Graph one" string, it took on of each of these and aligned it, as they are separate items (because a it's a list of characters).

Enclose your string in a list:

load_Profileout.AddRange(['Graph one'],gh.Kernel.Data.GH_Path(0))

Please attach your .gh/.3dm files next time.

Djordjie,

Thanks again for being so helpful after your comment I now understand what it means in the Grasshopper SDK that DataTree(t).AddRange method is takes an IEnumerable: it will iterate over every in the method.

In 99% of the cases when IEnumerable of a certain type is required, you can use a regular python list. There are few rare exceptions where you would have to use .NET list or array.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service