Revit on the Web: Using MVC and Database Views

4 Feb

In my previous post, I showed how you could use MVC and the Entity Framework to create a webpage that displays and edits a Revit model without typing any code. In that post, you connected your page to a table in the Revit Database. But what if you do not want the whole table to be editable or returned? In this post, I will show you another way to display your Revit data.

The Use Case

Using tables is the easiest way to connect to the information you need in Revit. But not everything in the table may be needed. During my days as a facility planner, I needed clients to edit room information. If I connected to the rooms table there would be way too many, most of which would be unnecessary. I was only interested in classrooms, so why should I display the hallways, electrical closets or bathrooms on my page. Also, I do not want the client to accidentally modify one of these rooms. I only want them to see the relevant data. Nothing more. Nothing Less.

The Database

While you could probably modify the model in the MVC Application to handle the filtering and removal of rooms, it is much easier to do so in the actual database. The database allows you to create views. A view can be a single table queried or multiple tables all joined in to one table. To test out a view in my MVC application, I created a view of rooms where the area was greater than 10.

Select * from rooms where area >10. Returns 7 rooms.

Select * from rooms where area >10. Returns 7 rooms.

Results

Now, you can create your MVC application as you did in the previous post, but this time you will select a view instead of a table. This view is live. If a room is added to the model and it has an area greater than 10, it will show up in our view. I have pulled the database back in to Revit and it is clear that Revit does not care if our database has views. It seems that Revit only pulls the tables back – and only the table or tables you specify. the image below shows the tables page of my application with only 7 records.

Rooms page based on view

Rooms page based on view

 

Advertisements

3 Responses to “Revit on the Web: Using MVC and Database Views”

Trackbacks/Pingbacks

  1. Weekly Roundup – 2015.05 | The BIMsider - February 6, 2015

    […] Revit on the Web: Using MVC and Database Views  […]

  2. View and Edit Revit Models: Add a Filter Using Code | Architecture and Planning - February 17, 2015

    […] how to view and edit Revit models on the web without writing any code. I have also shown you how to filter the views using a very little SQL in your database. In this post, I will show you how, in a few lines of code, […]

  3. .NET WEB API: REST Endpoints with C# | Architecture and Planning - March 2, 2015

    […] have posted here and here on using MVC 5 to edit a database with no code but as much as I like MVC 5, there are times that I […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: