There are a few snippets in your code that seem odd.
- On line 37 I would replace the part between parenthesis with the ‘loop’ you created on line 30
- On line 32 you should uncomment the ToRevitType() part and also put it between the parenthesis
Alternatively you could take a look at the code in these nodes from the MEPover package: