Hi,
In regards to the view creation, here is a bit of the “cleaned-up” code.
The issue that I saw being created is when you feed the titleblock Id it doesn’t work in newer versions of Revit so you need to feed the Family Symbol Id.
Please give this a try and let me know.
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
element = UnwrapElement(IN[0])
elementId = element.Id
tb = UnwrapElement(IN[1]).Symbol.Id
viewlist=[]
schedlist=[]
sheetlist=[]
# Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
views=[]
if IN[2]:
v=AssemblyViewUtils.Create3DOrthographic(doc,elementId)
views.append(v)
if IN[3]:
ds2=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.HorizontalDetail)
views.append(ds2)
if IN[4]:
ds3=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.ElevationTop)
views.append(ds3)
if IN[5]:
ds4=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.ElevationBottom)
views.append(ds4)
if IN[6]:
ds5=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.ElevationLeft)
views.append(ds5)
if IN[7]:
ds6=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.ElevationRight)
views.append(ds6)
if IN[8]:
ds7=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.ElevationFront)
views.append(ds7)
if IN[9]:
ds8=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.ElevationBack)
views.append(ds8)
if IN[10]:
ds9=AssemblyViewUtils.CreatePartList(doc,elementId)
views.append(ds9)
if IN[11]:
ds10=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.DetailSectionA)
views.append(ds10)
if IN[12]:
ds11=AssemblyViewUtils.CreateDetailSection(doc,elementId,AssemblyDetailViewOrientation.DetailSectionB)
views.append(ds11)
viewlist.append(views)
if IN[13]:
sh = AssemblyViewUtils.CreateSheet(doc,elementId,tb)
for v in views:
if Viewport.CanAddViewToSheet(doc,sh.Id,v.Id):
Viewport.Create(doc,sh.Id,v.Id,XYZ(0,0,0))
else:
ScheduleSheetInstance.Create(doc,sh.Id,v.Id,XYZ(0,0,0))
sheetlist.append(sh)
doc.Regenerate()
# End Transaction
TransactionManager.Instance.TransactionTaskDone()
OUT=viewlist,sheetlist
Hope it helps.