Placing Multiple Views on Multiple Sheets

This Python will make what I think is the solution sought at this post given 3 flat lists.

#proposed by Julien Benoit @jbenoit44 
#updated by @truevis
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

sheets = []
for i in IN[0]:
	sheets.append(UnwrapElement(i))
views=[]	
for i in IN[1]:
	views.append(UnwrapElement(i))
points=[]	
for i in IN[2]:
	points.append(UnwrapElement(i).ToXyz())

# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
viewp=[]
#for s in sheets:
#	for v,p in zip(views,points):
#		a=Viewport.Create(doc, s.Id,v.Id, p)
#		viewp.append(a)
cnt = 0		
for cnt in range(len(sheets)):  
    a=Viewport.Create(doc, sheets[cnt].Id,views[cnt].Id, points[cnt])
    viewp.append(a)

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT=viewp

Usage:

1 Like