Grasshopper

algorithmic modeling for Rhino

Hi, everyone I am new to grasshopper, but i like it already!

 

What i want to do is match a List of Letters to specific numbers.

Lets say i have

 

A

D

E

G

A

D

 

I want to get 

 

1

4

6

7

1

4

 

Is like saying A=1, D=4, E=6, G=7. The series of Letters is Long but the different letters are only 10 I don't know if that makes any difference.

 

Thanks!

 

Views: 7102

Replies to This Discussion

How about this. (although A=0)

First of all thanks for helping me m8!

ok on the first purple thingy, you are choosing from an alphabetical series of letters, some specific letters. I don't want that, because i cannot control the numbers assigned to the letters. Maybe i should clarify that i am using an XL script to create the series of letters, i don't need a method to produce them. 

 

I am not realy sure i get the second one. I wasn't able to replicate those result using my series of letters. You have a series from 0-25 and you are removing all but 3 numbers using a function. I don't understand the function and how am i able to asign specific numbers to letters. 

 

p.s. What the {0;0;0} on the last panel mean? 

How about a collection of String Replace components. You could set them up by hand (a bit annoying I agree) and you can then convert any letter into any numeric value you want. The letters have to be in separate strings for this to work though, otherwise you start to combine the digits.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 

omg thank you!!!! I was trying the replace compoment but couldn't realy get it till i saw your pic! :D

 

It is not so frustrating because as i said there would be only some type of letters! 

 

Thank you all!

Hey David are there any ways currently available to do what you've done above but within a single component?

Also, if anyone's interested here's my method for a simple alphabet > number translation (e.g. 1234 to ABCD):

  1. Use a Sequence component to generate an alphabet of the desired length and then create a matching number list using the List length and Series components.
  2. Use the alphabet and number list results to establish a key/value relationship in the first two inputs of the Key/Value Search component.
  3. Place any alphabet sequence, alphabetical or mixed, into the Search input of the Key/Value Search component to get the matching numerical list.

This will work for changing A to 0 or AA to 26 but will not work for changing AA to 00. For that you should utilize the String Replace component as David has above.

Hi All,

I ended up making a Wombat user object to address my questions above and work in both conditions (where AA can equal either 11 when considered individually or equal 27 when considered together like in Excel columns) - it includes some ridiculous error checking with Gh testing + stream filters which I'll likely replace with more efficient Python when I revisit. Let me know your thoughts.

Best,

Brian

Attachments:

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