Hey guys,
I am trying something very simple I think, however I have struggle putting it into code.
I have to surface components in grasshopper and two surface output components (ideally).
Depending on whether component A and or B are empty or not, the output components shall have specific data or not.
Example Function Idea:
if A = Empty and B = Empty:
return A = Empty and B = Empty
if A = Empty and B = True:
return A = B and B = Empty
if A = True and B = True:
return A & B
if A = True and B = Empty:
return A & B
I think the required code snippet is quite small however I struggle with the Python Component in terms of accessing and outputting surfaces.
Does somebody have an idea to my problem?
Looking forward to your help.
Best Regards
Max
SwitchSurface.gh (9.6 KB)
So you are expecting text output? I canât quite make sense of your logic but have always used the Combine component for similar situations:

If A is valid return A, otherwise return B.
Additional inputs can be added.
Hey Joseph,
no I dont want text ouput, I want surface output. E.g. if a gh surface component is empty it shall be filled with a surface from another component and that component shall than be empty.
Do you know what I mean?
You lost me with the words in bold. Otherwise, what I suggested does exactly that.
P.S. Actually, this confuses me too: âit shall be filled with a surface from another componentâ. So no, maybe I donât understand you at all.
I am sorry I try again:
I have two surface components in grasshopper, call them A and B
One of them contains a surface, the other one is empty.
Should A be empty and B have a surface, I want them to be switched, so that A gets the surface connection and B becomes empty.
Does this makes more sense to you?
Thatâs what I thought you meant, and no, it doesnât make sense to me.
You mean it doesnt make sense to you that i want to do that or you still dont understand what I want to do?
I need the Outputs for post processing, however, currently âOutput Aâ refers to âSurface Type Aâ and âOutput Bâ refers to âSurface Type Bâ.
Should, however, Surface Type A be empty and Surface Type B have a referenced Surface I want to use that referenced surface in Output A eventhough it is originally coming from B.
Of course i can just move the wire from Surface Type B to Output A, but this must happen without me checking it manually.
Do you understand the Combine component I suggested? That would be your âOutput Aâ. Iâm done here.
Thats not what I need, but thanks anyway
Convoluted logic, hard to imagine how this is useful. I donât know if this covers all your combinations:

SwitchSurface_2022Oct22a.gh (8.0 KB)
1 Like
This is actually doing exactly what I want thank you so much.
Regarding the logic, well yes, I guess there is an issue further upstream, but I could not figure that out yet because its quite complex and would not even know the question I want to ask.
In the long run there might be another workaround, but for now this is perfect, thank you very much.
Best
Max