Python not working at all

I can’t get a python script to run - it just always returns null. Even when I comment out everything except the input and a number.

## 2017/07/19
import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import System
from System.Collections.Generic import *

doc = DocumentManager.Instance.CurrentDBDocument

view = IN[0]
elements = IN[1]

#view = UnwrapElement(IN[0])
#elements = UnwrapElement(IN[1])


#TransactionManager.Instance.EnsureInTransaction(doc)

cnt = 0
#while cnt < len(view):
#	v = view[cnt]
#   	ids = list()
#    helements = list()
# 	for i in elements[cnt]:
#		if not i.IsHidden(v) and i.CanBeHidden(v):
#		ids.append(i.Id)
#	helements = List[ElementId](ids)	
#	v.HideElements(helements)	
	cnt = cnt+1

#TransactionManager.Instance.TransactionTaskDone()

OUT = list(view,elements,cnt)

It should return what was put in it and value of cnt.
Why doesn’t it return anything?

You should delete the tab at the front of line “cnt = cnt+1” so that “cnt = 0” and “cnt = cnt+1” have the same indentation level. Once you unmark the while loop, add the tab back so line “cnt = cnt+1” is one level down.

I know this is very subtle. But python scripts execution rely on correct indentation.

You live and learn…Indentation is critical in Python.
Still doesn’t work though.

## 2017/07/19
import clr
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import System
from System.Collections.Generic import *

doc = DocumentManager.Instance.CurrentDBDocument

view = IN[0]
elements = IN[1]

#view = UnwrapElement(IN[0])
#elements = UnwrapElement(IN[1])


#TransactionManager.Instance.EnsureInTransaction(doc)

cnt = 0
#while cnt < len(view):
#	v = view[cnt]
#   ids = list()
#   helements = list()
# 	for i in elements[cnt]:
#		if not i.IsHidden(v) and i.CanBeHidden(v):
#		ids.append(i.Id)
#	helements = List[ElementId](ids)	
#	v.HideElements(helements)	
cnt = cnt+1

#TransactionManager.Instance.TransactionTaskDone()

OUT = list(view,elements,cnt)

  1. Copy the python node from the Custom Node into your graph and test. Unfortunately when wrapped in a CN, exceptions/ warning messages get surprised which disguises problems
  2. You declare list() which isn’t a method or def and that’s likely to be creating the error and subsequent failure of the node. To output multiple objects from a python node, just comma delineate: OUT = view, elements, cnt

Success ! Thanks Thomas. Python no longer broken.
Now to fix my code. It is possible my code wasn’t working because of incorrect indenting. I’ll tackle that tomorrow.