Tag Archives: BIM

View and Edit Revit Models: Add a Filter Using Code

17 Feb

I have recently shown you 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, you can create a search box to filter the results in your pages.

Application Layout

In an MVC application, you have a model, controllers and views. As explained in an earlier post, The model holds the data from the table or tables selected. The controller sits between the model and view performing actions and responding to events which are sent to the model or passed to the view. The view is what you actually see when you load the page. the image below shows the layout of a simple Revit MVC Application.

Capture

I have a Revit mode, controllers for Rooms and Walls and views for the Rooms and Walls. There are separate views for each of the CRUD functions. There are other views, models and controllers that are created by .NET by default. Feel free to ignore these at the moment because we will not be using them.

To add filtering to our application, we will need to modify the Rooms View and Controller.

Rooms View

There are several views in the Rooms folder, but for our application we want to modify Index.cshtml. This is the view that returns the entire model – list of rooms in our database.  You can see in the code that the view creates a table with all the properties for each room in our model.

table

We want to limit the number of items in the Model returned from the controller using a search box. Let’s add the search box to the view. As in standard HTML, we can use a textbox and a button in a form. With MVC, however, we are using the Razor view engine so the code is slightly different.

@using (Html.BeginForm())
{
<p>
Find by name: @Html.TextBox(“SearchString”)
<input type=”submit” value=”Search” />
</p>
}

The code above should make sense if you are familiar with HTML. The only thing that stands out are the lines starting with the @ symbol. These are variables/expressions in Razor. The above code will create our search box.

box

Rooms Controller

Now that we have the form, we need to create the code in the controller that will handle the request. The first ActionResult in the code is the Get Rooms function. This is the code that returns the Index.html file we see in the view. The code below will make our search box work.

public ActionResult Index(string searchString)
{
var rooms = from r in db.Rooms
select r;
if (!String.IsNullOrEmpty(searchString))
{
rooms = rooms.Where(r => r.Name.Contains(searchString));
}

return View(rooms.ToList());
}

when we browse to the Index.html page for the first time, we will see all the rooms in the database. This is because the string searchString is empty. So rooms is equal to the contents of the entire database.

var rooms = from r in db.Rooms
select r;

Once on the page and having entered a value and clicked search, we have requested the Index.html page again, but this time with a value for searchString. Now the controller populates the value of rooms with only those records where the string is in the name.

rooms = rooms.Where(r => r.Name.Contains(searchString));

The function always ends by returning the View (the one with the same name as the controller) and passes it the values of our rooms variable – either all of them or a filtered list.

the images below show rooms filter by the word Master and even by just two letters. The code above uses Name.Contains not Name.Equals. this allows us to get results without exact matches.

Master

ContainsEN

This little bit of code has greatly improved our application. The code can be modified to search on additional fields and added to other views – like the Walls Index.cshtml view.

 

Advertisements

Revit REST API: More Detail

29 Jan

I have ideas in my head about why a Revit REST API is cool and what it can do. I also know that I fail to explain or show what I am thinking in the best possible way. Often, my examples are quick and dirty. I really love the Revit REST API idea and have built out a slightly more detailed example to show what can be done. The images below show a more complete site. I have sorted many of the tables by the field that makes the most sense. Remember, the data can be edited – without a Revit license I might add.  The model I used was the sampel that comes with Revit 2014.

The sample model

The sample model

walls

rooms

levels

sheets

views

 

BIM: Split vs. Merged Models

1 Nov

As we move to BIM, architects need to acquire new skills, particularly in the area of information systems. In school, magazines, and competitions, images are what matter – design is king. Design will always be important, but we are in an information age of architecture. BIM, Energy Modeling, and Form Finding using Scripts are the new architecture. Databases have become a tool of the trade and I fear that architects are lacking in their knowledge of them – if you refer to an Excel spreadsheet as a database, you are lacking. I am not advocating that architects become programmers and information systems experts, but I am suggesting that without at least basic skills you will fall behind. AutoCAD has had a LISP environment since 1986 yet the majority of architects I know would tell you that LISP is a speech impediment. How little knowledge we have of our tools. It’s like using a pencil but ignoring the eraser on the end and starting over whenever you make a mistake.

 

My interest today and the reason for this post is to offer my two cents on the difference between split and merged models.

 

Simply put, a merged model is a model with geometry and data combined. This would be a Revit model where all the data about the objects – rooms, walls, doors – exist in the model. This is the model type that Revit leads you toward. And what happens when you embed large amounts of data in to Revit? Your file size becomes massive and performance takes a hit. For what? So that you can create a schedule later or to color code a floor plan? What if you need this data for something else? Are you going to export it to CSV every time you need it? What about a client? Are they going to need Revit to update the information about their building?

 

A split model, on the other hand, is where the geometry and the data are in different systems. The geometry is in your Revit model and the data is in a database – SQL Server or MySQL. A split model is superior to a merged model and this is what we should be aiming for.

 

There are certain pieces of data that will always be in Revit. The area of a room or a wall should be determined by the geometry, not entered in a database. But the overriding point is that the model should have the geometry and an ID for each object. That is all. You should have a database with tables for Walls and Rooms and these tables should have an ID and the rest of the data – use, type, department, fire rating, load bearing.

 

So how do we create schedules and create fancy color coded plans without the data? We use a JOIN and connect the tables of data to the geometry based on the ID.

 

The data about our building will change far more often than the building. Painting walls, replacing doors or carpeting can be updated in a database. The model only needs to be updated when something is added – an addition – or removed – demolition.

 

Another reason for split models is that we should keep our tools separate. Do you really need a 3D modeling application to also be a full blown database application? No. We only need the ability to connect them. Let Revit do what it does best – model.

 

Planners use split models in GIS, programmers use a Model-View-Controller framework and web developers have been working to remove the code and logic from the design of web pages for years. This is nothing new. Architects need to look at how other professions have solved this problem and learn from their best practices. I remember a quote from an officer in the Coast Guard that went something like this: “The data about our buildings is worth more than the buildings themselves.”

When Architecture and Planning Mix: BIM and GIS

20 Mar

Architects and planners work at two different scales and use two different sets of software. Architects use computer aided drafting (CAD) and Planners use geographic information systems (GIS). Architects are often drafting a single building on a site and planners are analyzing a block, neighborhood, city or region. It is not that often that a planner works at the level of a single building and it is just as rare to find an architect drafting a city. What if we could combine the work of architects and planners in GIS?

Read More at The Urban Times…

It’s Not Revit, It’s You.

15 Mar

It has to be said: Revit is not the problem, YOU ARE!

Let me explain….

I sat down this morning to listen to a licensed architect ask how to find out wall areas in Revit. After hearing the answer, the architect asked for the drawings in CAD. Because using DOS and CAD – yes, DOS was actually used, I can’t even make that up – is faster and Revit is inefficient and doesn’t do the things it needs to do. How can it have so many tools and capabilities but none of them are relevant to our work.

I hear this way too often. Revit can’t do X. Or, AutoCAD is much faster at X than Revit. This is wrong! There is very little that you can’t do in Revit, you just don’t know how (let me say that for the work I am doing there is very little it doesn’t do). CAD is faster because you have been using it for 15 years. Trust me, when you get proficient in Revit,you will find many things much faster.  I offered to put a cost formula in the template that will calculate the costs of painting the walls. “But I don’t need to paint them all.” I know, but when the model is drawn for every future project those costs will be in the model. Just select the walls you want and you are done! How about stucco? Want me to add tile and carpet on the floors? No Problem.

Was my offer accepted? NO.

Did you know you can export it to AutoCAD – sorry, we don’t have DOS so you will have to use Windows. NO.

The architect printed out the floor plan and is calculating the area with a ruler!

 

 

Don’t Get BIMBoozled

6 Feb

I love BIM. I think it is a great process for the AEC industry. I also think that it has become a buzzword. Architecture firms are putting BIM in every piece of marketing material. They are telling their clients that they “use BIM” and how this makes them the right firm for the job. But it’s not just architects throwing BIM around. Owners are doing it too. RFPs are requesting firms with experience in BIM. Do these clients actually know what they are getting or why they need BIM? All I am asking is that if you are going to promote BIM or if you are going to request a firm to have BIM experience, at least know why you are doing this. I want to share a sample contract that pushed BIM. This contract is real. I stumbled upon it while searching the web. The names have been removed to protect the innocent, and the not-so-innocent.

Convert existing as-built construction documents of all facilities…into REVIT, an electronic building information management system…After the REVIT drawings have been generated, COMPANY will walk through each facility to verify the information. Inconsistencies …will be corrected on the REVIT drawings. The REVIT drawings will be for information only and should not be used for construction documents without verification of dimensions and room layouts. Electronic files of each facility will be provided to the District in both .pdf and REVIT format.

The first thing to notice about this contract is that it never mentions BIM, but rather is selling Revit drawings. It is clear from the second sentence that Revit is equated with BIM. However, the writer of the contract is not clear on what the acronym BIM actually stands for and states that Revit is a “building information management” system. Revit is not BIM. And BIM stands for Building Information Modeling.

Secondly, The company will verify the information in the Revit drawings. What information? This is the whole scope of work detailed in the contract. At no point is there any reference to what the I in BIM is to include. It appears, from the few sentences I have truncated, that the Revit drawings will be drawn to match the as built conditions. Having a floor plan that is accurate is not usually what the I in BIM stands for. Also, it is interesting that the drawings will be verified but should not be used by the client unless they are verified again. It’s almost as if the company is stating that they will not verify them very well. Lastly, on this point, the drawings are for “information only.” Again, the use of the word information, without any clarification as to what this means. If you are just giving me a floor plan, why do I need it in Revit? Can’t you do it in AutoCAD? Am I paying more for this because Revit is being sold as BIM?

My last criticism of this contract is that the deliverable is a “.pdf and Revit format.” I can guess what this means, but in contracts one should not have to infer what the deliverable is, it should be stated clearly – unless you like litigation. A “.pdf” is a specific file type. The contract makes no statement as to which program would be used to create it. A PDF of a 2D floor plan from Revit, however, removes any “information” that may have been included in the model. I cannot click a window and see the properties. The drawing is now no different than if it were done in CAD. The second deliverable is a drawing in the “Revit format.” A filetype was not stated, as was done in the first deliverable, but rather the software used to create it was. We can guess the filetype would be a .rvt. That’s great, but does the client have Revit? would a DWF and a copy of Design Review make more sense? They would then have access to the data in the model. How about an .ifc and a copy of FZKViewer? Let’s hope the client has Revit and can utilize this deliverable.

What is an .rvt? I know I can save as.. and pick .rvt, but what should that file look like when I open it? Should it be 3D? What level of detail is the model built to? Are the walls generic? This contract does not say. It is wide open to interpretation. This contract is an example of someone getting BIMboozled. It appears that neither the client, nor the company, knows what BIM is. What is being sold in this contract? What does the client think they are buying? I wish I knew.

Architects, if you are going to write your own contracts, please have a lawyer look them over.

Clients, if you are going to sign a contract, please know what you are getting and make it clear — in writing!

And finally, if you are going to promote or require BIM, know why you are doing so. Don’t just use buzzwords.