Threshold divide by zero

Hello,

The Threshold Selector gives an error due to division by zero. I see that the “totalArea” in the code is the issue (line 185). Can this be fixed by creating an if-statement which set the totalEnergy to sum(shadeNetFinal) if totalArea is 0?

From the code:

    #Calculate the total area and the energy saved by the new mesh.
if _inputMesh.Faces.Count == len(_analysisResult):
    totalArea = sum(areaList)
    totalEnergyList = []
    for count, area in enumerate(areaList):
        totalEnergyList.append(shadeNetFinal[count]*area)
    totalEnergy = sum(totalEnergyList)
else:
    totalArea = rc.Geometry.AreaMassProperties.Compute(newMesh).Area
    totalEnergy = (sum(shadeNetFinal)/len(shadeNetFinal))*totalArea

return totalEnergy, totalArea, newMesh, joinedCrv

Best regards

Hi @TK, you should probably post this issue to GitHub. It will get lost in the forum. Thanks.

Thank you @mostapha, I’m not familiar with GitHub, but created a account and posted the issue:

Hope this helps

Best regards.

Thanks. I moved it to the right repository and we will hopefully address it soon.

Great, thank you for the help.