I enjoyed the course but I did spend 1.5 days trying to troubleshoot what I was doing differently (I refactor code as I wr...

I enjoyed the course but I did spend 1.5 days trying to troubleshoot what I was doing differently (I refactor code as I write it to make sure I understand it) and was getting a divide-by-zero error. Finally, opened the finished file, ran it and looked at the console, guess what... :p a lot of time spent troubleshooting in the wrong direction since I had actually followed the code correctly. Just a note for anyone else. The code runs, but it does throw an error. If anyone wants to troubleshoot it, do it with that in mind. :)
  • Markus Berg(thebergh) replied

    The simplest way to deal with the 'ZeroDivisionError' in the script would probably be to change

    obj.location = sum / n

    to

    if n > 0:
        obj.location = sum / n

    Not necessarily the cleanest way, but it works.

  • gorgious replied

    Another way to ensure that the delay doesnt get below 1 :

    if not empty.get('_RNA_UI'):
       empty['_RNA_UI'] = {}
    
    empty['delay'] = 10
    
    empty['_RNA_UI']['delay'] = {
    "default": 10,
    "min":1,
    "max":1000}
    
    

    Found on https://blender.stackexchange.com/questions/143975/how-to-edit-a-custom-property-in-a-python-script

    But it's always good practice to ensure Exceptions like zero division error won't be thrown inside the code since the property can be modified by the user