GetBoolean if else

Hello,

Here’s a simple script asking the user to choose between square or rectangle and print the result accordingly. Question: why is the answer always square?

import rhinoscriptsyntax as rs

items = [("ChooseType", "Square", "Rectangular")]
footPrintType = rs.GetBoolean("Footprint types", items, (True))
if footPrintType == False: 
    print("You've selected a rectangle")
else: 
    print("You've selected a square")

As per the documentation GetBoolean returns a list of truth values. Additionally, the first choice will return False, the second True as explained in the same documetation.

So your script should be:

import rhinoscriptsyntax as rs

items = [("ChooseType", "Square", "Rectangular")]
footPrintType = rs.GetBoolean("Footprint types", items, (True))

if footPrintType[0] == False: 
    print("You've selected a square")
else: 
    print("You've selected a rectangle")

Ah yes, thank you very much for clarifying!