<reponame>andydandy74/ClockworkForDynamo<filename>nodes/2.x/python/All Elements Of Category+.py<gh_stars>100-1000
import System
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

def ElementsByCategory(bic, doc):
	collector = FilteredElementCollector(doc).OfCategory(bic).WhereElementIsNotElementType()
	return collector.ToElements()

inputdoc = UnwrapElement(IN[2])
if not inputdoc: doc = DocumentManager.Instance.CurrentDBDocument
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.RevitLinkInstance": doc = inputdoc.GetLinkDocument()
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document": doc = inputdoc
else: doc = DocumentManager.Instance.CurrentDBDocument

if isinstance(IN[0], list): OUT = [ElementsByCategory(x, doc) for x in IN[0]]
else: OUT = ElementsByCategory(IN[0], doc)