algorithmic modeling for Rhino
Hello everyone, I need to change RGB coordinates coming from Image sampler into numbers.
I tried with python but it seems there are problem with the component .. is there a way to make it in GH in this way:
if variable is 0,0,128 x = 0.5
if variable is 0,0,255 x = 1
else (for everything else) x = 2
thank u!
Tags:
Thank You Danny!
Actually I've already tried with the replace text component and it work, the only think I couldn't manage is the else statement at the end.
I mean, I'm able to change all the colour that i want but not able to manage the remaining ...
any suggestion about that?
really thank you for your help
Is what I have in the image not what you want?
Basically From the Second [Replace Text] to the [Replace Items] is all about the what else
...and the "no hit" text box should of course show "2" for all the non-hits.
Instead of a text box of colour integers, you could also plug colour swatches into the integer parameter.
/ola
Too late, as the cavalry already arrived.
Nevertheless, here is the python solution:
import Grasshopper.DataTree as ghdt
import System
newTree = ghdt[System.Object]()
paths = col.Paths
branchLists = col.Branches
for i,branch in enumerate(branchLists):
branchL = []
for item in branch:
if (item.R == 0) and (item.G == 0) and (item.B == 128):
num = 0.5
elif (item.R == 0) and (item.G == 0) and (item.B == 255):
num = 1.0
else:
num = 2.0
branchL.append(num)
newTree.AddRange(branchL, paths[i])
a = newTree
dear djordje
do you known any particular sourches where to learn managing example you have attached?
thanks
A
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by