Grasshopper

algorithmic modeling for Rhino

If you have several values under one index (I guess this is called a string) how can you change it into one index for every value (I'm guessing this would be a list)?

 

Best,

 

Troels

Views: 7618

Replies to This Discussion

How are you values separated?

 

Use this to split the string.

 

I'm playing around with a gHowl selfloop script. It works great when just sending and receiving one value, but comes out as shown in the screenshot when trying to send and receive a list.

 

I don't have any seperators which, I guess, may also be part of the problem. Is there a way to add seperators or split the kind of string that I have?(if not actually a list - my definitions are a bit shaky - sorry)

Attachments:

Try this

The panel input to the c is blank

You guys are truly amazing! :) Thanks
By the way. The panel to the left; what do we call that? List, String, Numbers-below-eachother or something else? :)
I'm not sure I understand the question. I created the list of numbers in a standard panel with the "multiline data" property enabled. Its effectively 0&vbCr&1&vbCr....etc where vbCr represents a Carriage Return in Visual Basic

I just wanted to know what the term for it was. Is it a list, a string or just 'numbers in a panel' or maybe something beyond my terminology.

I think technically its a multiline string of numbers. Also remember anything output from a panel is a string and needs to be parsed by GH to interpret what you intend it to be. Sometimes GH fails and you need to pass it through a param like Number or Integer to indicate what the string should be.

Danny, does disabling the "multiline data" in the first panel, solve the problem?

Troels Heiberg Frandsen has this:

and he wants this I guess:


I am not trying to act like smart, I am just asking as a newbie, because I had the same problem in here.

Hi Djordje,

You can only disable the "multiline data" if the text originates in the panel i.e. you typed it.

If you are importing a string from outside of GH, like Troels was in this particular example, using the >UDP< component from gHowl.

As I didn't have the data stream I was mimicking it with the panel. 

I understand. Thank you.
One more question:

I perfectly understand this solution of yours:

Commas characters are separating the numbers, and we just "told" Split string component to split the data row, on each place where there is comma.

But I do not understand this solution:

The numbers are separated by some sort of new line characters (is there such a thing) not by " " space(blank) character. So why are we splitting it, with " " space character?

And why are we getting those <empty> parts in each second row, too?

The contents of the panel do not consist of a space character " ". It contains nothing "" which results in a split of the string at every single character including the New Line control character hence the cull Nth component to remove the New Line <empty> results.

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