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:

1
2
3
4
5
6
7
8
9
 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
         break

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.

1
2
3
#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 *

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>