This package only works for a single view and type.
I was looking for a version that can take lists of points, types and views as inputs so I modified the code.
My python skills are limited to cut and paste, so whenever I find a package that only does single items and need to process a list I use Konrads truly excellent ProcessParalelLists method.
Here is the code if anyone needs it;
# ProcessList and ProcessParallelLists methods with many thanks to
# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
# whos excellent code I have shamelessly appropriated as a standard template
# Import Element wrapper extension methods
import clr
clr.AddReference('RevitNodes') #Always use ' not '' to keep it dynamo code block freindly
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import System
from System.Collections.Generic import *
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def ProcessParallelLists(_func, *lists):
return map( lambda *xs: ProcessParallelLists(_func, *xs) if all(type(x) is list for x in xs) else _func(*xs), *lists )
def Unwrap(item):
return UnwrapElement(item)
RunIt = IN[0] #First input is always on off switch
if isinstance(IN[1], list):
points = IN[1]
else:
points = list(IN[1])
if isinstance(IN[2], list):
famtypes = ProcessList(Unwrap, IN[2])
else:
famtypes = list(Unwrap(IN[2]))
if isinstance(IN[3], list):
views = ProcessList(Unwrap, IN[3])
else:
views = list(Unwrap(IN[3]))
# if isinstance(IN[3], list): #If input is not a revit element, do not unwrap
# names = IN[3]
# else:
# names = list(IN[3])
#Define output list to be appended in functions
elementlist = list()
def PlaceInstances(point, famtype, view):
newobj = doc.Create.NewFamilyInstance(point.ToXyz(), famtype, view)
return elementlist.append(view.ToDSType(False)) #newobj instead of view for list of families
if RunIt:
errorReport = None
# run process
ProcessParallelLists(PlaceInstances, points, famtypes, views)
else:
errorReport = 'Please set the RunIt to True!'
#Assign your output to the OUT variable
if errorReport == None:
OUT = elementlist
else:
OUT = errorReport