IronPython error - 'NoneType' object has no attribute 'ActiveUIDocument'

I have been working with this code all week (only snip included) and then it just stopped working.

image