Hey guys, I just recently started my GH journey and I am keen to learn as much as I can. I made a couple very specific definitions so far which I’m proud of mainly because I actually did make them (lol) and I plan to keep moving forward.
Now, the thing that I want to do is:
select a bunch of curves and
if the length is less/equal to 30 - don’t divide the curve(s),
if the length is more than 30 and less/equal to 48 - divide the curve(s) into 2 segments,
if the length is more than 48 and less/equal to 72 - divide the curve(s) into 3 segments,
if the length is more than 72 and less/equal to 96 - divide the curve(s) into 4 segments.
If you guys have any ideas how to break down this kind of logic within GH I would be more than grateful for your help.
def returndivisions():
if x.GetLength()>30 and x.GetLength()<=48:
return 2
if x.GetLength()>48 and x.GetLength()<=72:
return 3
if x.GetLength()>72 and x.GetLength()<=96:
return 4
# default
return 1
a = returndivisions()
You can try a pattern of Find Domain and then Pick’n’Choose or Weave.
So the Find Domain will find which Domain each value ”belongs to”. This will output as a list of domain indices. The indices can be used to create a list of division counts (Weave comes into play here) or you can even set the domains in a certain order to directly output as division counts.
In general case that would be the vanilla GH way I would try.