Coming back to the topic of generating room plan views in Revit 2014 with Python. Now it is about Room Plans and View Templates. People had quite a few questions regarding (this one and that one) Python Room Plans posts and one of them was pretty legit – if we batch generate a bunch of floor plan views, one for every room in selection, why can’t we go ahead and assign the right view template to these views? We sure can, it is actually pretty easy, all we need is to add a few lines of Python code to the previous scripts:

 collectorViews = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views)
 #template name
 templateName = 'Test Plan Template'
 myTemplate = 0
 for view in collectorViews:
     if view.IsTemplate and view.Name == templateName:
         myTemplate = view

The code above takes care of receiving the view template name that we want to assign to the future room plan views and iterates over the collection elements of OST_Views category (those are regular views and templates) to find the right one.

#assign template to the view
         if myTemplate != 0:
             vp.ViewTemplateId =myTemplate.Id

This chunk of code above actually checks if the previous piece of code found the requested template and assigns it to every freshly created view. That is just about it. There rest is the same as in the previous blog posts. You can download the whole script below. Go learn Python and Revit API to skyrocket your effectiveness to the point that you will always have your beer early every Friday!

Share →

Leave a Reply

Your email address will not be published. Required fields are marked *