Grasshopper

algorithmic modeling for Rhino

Converting TXT file into sequential set of curves based on "if/then"

Hello Everyone,

I am new to Grasshopper and teaching myself how to use it by attempting a specific project that I have in mind:

I would like grasshopper to read a text file sequentially and for each specific character it encounters in the file a specific curve would be created (a line with a particular length/orientation associated with that specific character) whose starting point is on the end of the last previous line.  here is simple action list:

  • read first character in txt file 
  • identify character (number 20 in attached example)
  • insert line associated with character (1" horizontal line)
  • read next character in txt file.
  • identify character (number 8 in attached example)
  • start curve (specific curve associated with the number 8 (1.25" vertical line)) on the end of the previous line.
  • read next character in txt file.
  • identify character (number 5 in attached example)
  • start curve (specific curve associated with the number 5 (.25" horizontal line)) on the end of the previous line.
  • etc
  • loop repeats till end of txt file.

i am good with everything else (linking the file, building curves on the ends of things, creating line parameter w/ persistent data, etc) but I'm having a problem with the "if/then" nature of the project.  I haven't found a component that has this sophistication yet... I've tried the equals component that compare lists and identify true/false scenarios and the f(x) along with dispatch to create a curve if a single situation occurs (like if x>3, then make a circle) but what about the next character?

I am wondering if I should do this in C+ (which I also don't know) but would rather create this in grasshopper. 

See attached for example grasshopper file and txt file.

I would really appreciate any help you can offer - Thanks!!!

// jon

Views: 543

Attachments:

Replies to This Discussion

You can use Mass Addition to solve  this:

The Random component simulates your list of values from files, the Line SDL gives the list of associated lines.

To make it work the way you described, replace Random by your Read File, replace Line SDL by an appropriate list of lines (they should have origin as start point).

Attachments:

Wow - Thank you so much Systemig!!!

Question for you... I am a bit baffled how this system is associating the specific line type (that is generated in your example) with the specific character in the txt file.  So I replaced your randomizer with my txt file link and for example, every character "14" it encounters in the text file, it is inserting a vertical line 1.5, or for every "20" it encounters, it is inserting a line that is .75" in the x dimension... Is there a way to have more control over this?  I am looking at creating 66 specific curves and surfaces (lines, spheres, cubes, etc) that will be associated with 66 specific characters in the txt file.  

Would you be so kind as to illustrate how several different curve and surface tools can be associated with a specific character in the text file?  Attached are the grasshopper amendment and txt file... 

Wish i could offer you a digital six-pack for your help/troubles!

best and many thanks!

jon

Attachments:

Ok, let say you define a list of 66 different lines.

This list is ordered, lines are different, so there is a bijection (= one-to-one correspondance) between the indexes of lines [0 to 65] in the list, and the lines.

That means for example index i refers to line Li, and only Li.

Using List Item, it is trivial to get Li with i.

If you provide an integer not in [0 to 65] to List Item, you can get a result if the Wrap parameter is set to true, but it has no "meaning".

If you want your txt file to be different than numbers between 0 and 65, you can use the same method to make correspondances between characters and numbers.

Now if you want to use surfaces or polysurfaces, you have to decide how they will stack together, spheres and cubes don't really have "end points".

Attachments:

Thank you so much!!  This is giving me a ton to work with.  I really appreciate your help with this!!!  I'll send you a photo of the finished work ;-)  

All the best Systemig!!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service