LearnRevitAPI

Feb 19, 2024

Place Views on Sheets

❌ Stop dragging your views onto sheets in Revit manually!

I've got a much better example of using Revit API and python - a Way Better. I'll show you how to place views we created previously onto new sheets.

💡 You can see Full Video Tutorial on YouTube!

Brainstorming

So how do we place views on sheets?

I will keep it simple in the newsletter, but essentially, we need to complete 2 main steps.

1️⃣ Create ViewSheet
2️⃣ Place Views on Sheet by creating ViewPorts

And they are fairly simple.

1️⃣ Create ViewSheet

We all organize our views differently, so I will skip this step in the newsletter. However, you can see how I do that in the blog/YouTube video. Once you've gathered and sorted your views, we can begin creating ViewSheets

We will use ViewSheet.Create method, which takes 2 arguments: 
- Document
- TitleBlockId

We can easily get default titleblock using GetDefaultFamilyTypeId method, which takes familyCategoryId argument.

💻Here is the Snippet to get Default TitleBlock and create new sheet for each window in dict_views:

💡Note that I iterate through dict_views! You might get your views differently. (See the video)

2️⃣ Place Views on Sheet

Now that we have empty sheets, how do we add views there?

To place views on sheets we need to create Viewport. There is a method Viewport.Create, which  takes 4 arguments.

The first three arguments are fairly straight-forward. However, the position will vary depending on type of a view/views you are placing on the sheet.

I will keep it simple and hardcode position coordinates.

I will manually place views on 1 sheet, and then look with RevitLookup at values in Viewport.GetBoxCenter. This will allow me to get the right XYZ coordinates that I can use in my script. (Mainly I need X,Y, Z is irrelevant here)

This method might seem quick and dirty, but it suits my use-case well. Despite creating hundreds of sheets, only a few will require additional adjustments—primarily due to some windows being too wide.

Here is the Snippet:

💡 Don't forget to use Transaction ! It's supposed to be together with Creating Sheets.

✨Final Code

Lastly, if you want to learn more about it, I would recommend you to follow my  tutorial on YouTube or check the blog post I wrote.

I had much more space and time there to explain this concept, I hope you don't mind me keeping this email short.


Open Blog Post

Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 7200+ people!

Last Chance To Claim LIFETIME ACCESS. [~40 Seats left]