Lightning protection and grounding in Revit

Hello every1.
I took the material (Проектирование молниезащиты в REVIT - YouTube) on the design of lightning protection and grounding in Revit. I downloaded their example from the site, launched an example project and the attached script for arranging fixtures. The script didn’t work referring to division by 0, but unfortunately I don’t know enough Python to understand what could be wrong with this code.
I tried to put 0.001 in the wrong denominator in order to get at least some kind of answer. Then the code in the last block broke, swearing at the range boundary :frowning:
Maybe someone can explain what is wrong and how to fix it?
I can’t attach the project here, because it weighs a lot.

расстановка креплений ver. 1.4.dyn (29.4 KB)