Skip to content

Instantly share code, notes, and snippets.

@Cyril-Pop
Last active February 12, 2020 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cyril-Pop/0b482612b7c2bb0ff9a78034b13b2471 to your computer and use it in GitHub Desktop.
Save Cyril-Pop/0b482612b7c2bb0ff9a78034b13b2471 to your computer and use it in GitHub Desktop.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
templates = UnwrapElement(IN[0])
viewfamType = UnwrapElement(IN[1])
outviewplan = []
collLvl = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
TransactionManager.Instance.EnsureInTransaction(doc)
for template in templates:
for lvl in collLvl:
newvpl = ViewPlan.Create(doc, viewfamType.Id, lvl.Id)
newvpl.ViewTemplateId = template.Id
outviewplan.append(newvpl)
doc.Regenerate()
TransactionManager.Instance.TransactionTaskDone()
OUT = outviewplan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment