GPython code help to perform simple if then function

Hello,

Thank you to everyone ahead of time!
I am a complete noob when it comes to Python in Grasshopper and need some help to get started.
To sum it up I have made a simple script for FAR ratio massing generation, basically to see how tall/ levels I can go given a set criteria such as site area, setback lines and FAR ratio.
You can specify how many levels you want to go and then in return see if the total SQ Ft is greater than the allowable FAR ratio which returns a simple yes or no result.
If yes then the result is greater than allowed so i go one step below to reach allowable levels in the building. but that means there is still a bit of SQ ft left.
I want to make python component that in the event the result is “Yes” it displays the difference between Allowable area and the total area of the building.
Any help is greatly appreciated, let me know if you need more details as I know this all doesn’t sound very logical.Massing FAR Study.gh (21.4 KB)
Massing.3dm (121.8 KB)

Hi

You can connect both results directly to your GhPython Script component, and use something like this.

if x > y:
    a = x-y
    print(a)

HTH


Kaushik LS
Chennai, IN

Your code:

You don’t need an Expression and a GhPython Script to accomplish this.

You could use either the python script posted by @Kaushik, or this expression:

Also note that your connections are reversed: X input to the Expression is y input to the GhPython Script

-Kevin

Than you!

Thanks, ill try that!

You can also use Stream filter

And for python code you can correct it like this:

Yes it is a string you must use it like this 'Yes' and for a use equal (=)

image