pyRevit

Code

Library

Create View Sheet

# -*- coding: utf-8 -*-
#โฌ‡ IMPORTS
from Autodesk.Revit.DB import *

#๐Ÿ“ฆ VARIABLES
doc          = __revit__.ActiveUIDocument.Document
active_view  = doc.ActiveView
active_level = doc.ActiveView.GenLevel

#๐ŸŽด ALL TITLE BLOCKS
all_title_blocks = FilteredElementCollector(doc)\
.OfCategory(BuiltInCategory.OST_TitleBlocks)\
.WhereElementIsElementType().ToElements()

if not all_title_blocks:
    import sys
    print('There are no TitleBlocks in the Project! \nPlease Try Again')
    sys.exit()

selected_title_block = all_title_blocks[0]


#๐ŸŽฏ Create Drafting View
with Transaction(doc,'Create Drafting') as t:
    t.Start()

    new_sheet = ViewSheet.Create(doc, selected_title_block.Id)
    t.Commit()

__author__ = '๐Ÿ™‹โ€โ™‚๏ธ Erik Frits'

โŒจ๏ธ Happy Coding!
Erik Frits