I am very new to using Dynamo, but I have re-created a graph used to create views and place these on newly created sheets based on inputs from an Excel file. I would like to incorporate 3 additional inputs.
These inputs are as follows:
- Apply a View Template to the newly created views based on the Excel file (testing 3 different templates).
- Apply a scope box to a specific view based on the Excel file.
- Select the correct parameter in the keyplan based on the scope box or part of the sheet number (i.e. A-101B with B being the section of the building to be highlighted in the keyplan).
Python Script for āMake Sheetsā:
#Make Sheets
import clr
clr.AddReference(āRevitAPIā)
from Autodesk.Revit.DB import *
clr.AddReference(āRevitNodesā)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference(āRevitServicesā)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
sheetnames = IN[0]
sheetnumbers = IN[1]
titleblock = UnwrapElement(IN[2]) #unwrapped titleblock
sheetlist = list()
TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements
for number in range(len(sheetnumbers)):
newsheet = ViewSheet.Create(doc,titleblock.Id)# create a new sheet where titleblock.Id is the id of the titleblock
newsheet.Name = sheetnames[number]
newsheet.SheetNumber = sheetnumbers[number]
sheetlist.append(newsheet.ToDSType(False))
TransactionManager.Instance.TransactionTaskDone()
OUT = sheetlist
Python Script for āPut View on Sheetā:
#Put view on sheet
import clr
clr.AddReference(āRevitAPIā)
from Autodesk.Revit.DB import *
clr.AddReference(āRevitNodesā)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference(āRevitServicesā)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
sheets = IN[0]
views = IN[1]
x = IN[2]
y = IN[3]
viewsplaced = list()
TransactionManager.Instance.EnsureInTransaction(doc) # you need an active transaction as you will create elements
for number in range(len(sheets)):
sheet = UnwrapElement(sheets[number])
view = UnwrapElement(views[number])
Viewport.Create(doc,sheet.Id,view.Id,XYZ(x,y,0))
viewsplaced.append(view.ToDSType(False))
TransactionManager.Instance.TransactionTaskDone()
OUT = viewsplaced