Splicing a fixed-alphanumeric string

Long time Rhino user, fairly new to grasshopper but loving it. I’d like to create an algorithm where I can input a fixed 8-digit alphanumeric string ej. HP97O1FR, and I can splice out each digit into its own pathway and assign it a value, ej H=8, P=14, 9=35, then use those values to define for my geometries. My biggest challenge is splicing out the 8 digits into their own pathways. Sorry, not a CS guy…

Thanks in advance for your help!

Welcome,

You could try something like this.

Don’t worry! There’s really no need for scripting.

2 Likes

Thank you so much!!! This is exactly what I was looking for!! :pray:

Is there anyway you can post the GH file for this? I’m having trouble recreating it

Sure, here you go. It’s the exact same setup as above.

string-formatting.gh (5.9 KB)

See ya in half a year! :rofl:

1 Like

Thanks! I’m hung up on a problem… I’m assigning a color to all 36 alphanumeric numbers then coloring 16 geometries based on the alphanumeric codes(each geometry represents a digit in the code), the idea is every time you plug in a new 16 digit code, you get a unique result.
ColoredString.gh (33.4 KB)
I cant seem figure out how to connect the GH file to make this run, maybe I’m going about it the wrong way. Thanks in advance for the help.

I don’t get what you’re trying to do. All your file contains, ar 36 color swatches and a list item componnt.

Here is the concept with the Rhino File and GH file. Each cone represents a place in the 16 digit alphanumeric string. 16 digits = 16 cones. I’d like the color of each cone to be dictated by the number or letter in the string. Digit one is an H, and H is blue, so cone 1 gets colored blue. Digit to is P, and P is red, so cone 2 gets colored red…etc. The idea is each time you put in a new alphanumeric number you’ll get a new result.
ColoredGrid16x16.3dm (800.6 KB)
coloredstring16x16.gh (214.2 KB)

I would do something like this.

colors-16x16.gh (15.0 KB)

1 Like

I learn so much through these types of projects! This is so helpful! Thank you for putting the time in to help. :pray: :pray:

This is so close… except I would like every time the letter ‘f’ shows up for example the cone will be pink, and if there is a ‘9’ it will be blue, etc. With the current gh file, as long as I input a 16 digit code the result remains exactly the same, I want the code to dictate the colors of the cones, any hints at how to assign each alphanumeric character its own color?

Here’s an overall better, more robust, and less limited system!

You can now add as many rules as you like to the Rules group.
There only need to be as many characters in the input code as there are cones and all its characters need to be in the rule set.

A rule is composed of a set of one or more characters and a colour.

Screenshot 2022-08-06 at 17.45.21

Here the colour blue is matched to the characters H and 9.

colors-16x16-rev.gh (16.9 KB)

1 Like

Hi Chris,

Rather than laboriously setting up 36 swatches you might consider using the Colour Wheel component to generate a set of harmonious colours:

ColouredStringFromWheel.gh (34.6 KB)

Regards
Jeremy

1 Like

Another awesome solution, that color wheel will be fun to mess around with :fire: Thank you for putting this together! Very cool.