Generate geometry based on list of codes

Hi, I’m trying to work with some zones pulled in from ArchiCAD. I’m reading the code out of the properties, and I’d like to execute a series of commands based on what the code is for each zone.

Eg
if Code is F1.1h, draw this
else if code is F4.2, draw something else.

I can’t work out how to achieve this. Hoping for a solution that doesn’t use Python (more for my learning of Grasshopper than anything else). Wondering if the solution involves Sift Pattern or Stream Gate in some way? (Though I can’t get either to work).

Any help appreciated!

What does the data actually look like? Is it text?

I’ve got it into a list of text values:


I’m using 5 zones to test but potentially there’d be a couple of hundred. There will only be nine unique codes.

I’d use KeyValue Search component. You write your nine possible codes in a panel, use whatever shape you want to associate with those codes into another parameter, and then for each value, you use the Key search to look up which shape is tied to that code.

Thanks, I’ll explore that. The examples online seem to show the Values (which I understand to be the chosen output?) are in the form of a list. How would I do a series of possible commands instead? (Ie If code 1 then link to the Circle component, If code 2 then Box component, etc?)

Thanks for the advice, but I couldn’t get anywhere with KeyValue Search - if I input a list shapes as my potential outputs, then surely I’d still then need to run an If Then Else type command to actually generate the shapes - so I’m no further forward.

I’ve tried to achieve something using Python but still not getting anywhere.

Aiming to set it to draw either a sphere, box or cone in the centre of each Zone depending on the code in the properties. Python script and grasshopper components attached. I’m possibly aiming to run before I can walk here, but any advice would be much appreciated!

Edit: I’ve got there :slight_smile:

Took it back to basics and started a new script. Using Member Index and Sift Pattern. Posting the solution in case anyone else is interested.

Convert the list of inputs into numerical codes using Member Index, and then Sift the list into a series of geometry outputs.

1 Like