Saturday, 19 February 2022

How to link an IFC in place in Revit

 Linking an IFC in place in Revit can be difficult because there is no option to link it with shared coordinates. Even if the model was exported from a Revit file with the proper shared coordinates, this won't be translated into the IFC file. In this post, I will explain how I do it.

 

Preparation and initial checks

If a consultant sends you an IFC link you can ask them to include gridlines. In addition, if their authoring software doesn't work with coordinates as Revit does, they can put the origin of their file matching a grid intersection. This will allow easier placement of the file if the following methods don't work.

When I receive an IFC model I always check if the coordinates match with my model. To do this I combine an IFC file of my project with the consultant's model in a program such as Solibri or Navisworks. If the two models match in the same position, follow the next steps to align the models in Revit. On the other hand, if the models don't match and the consultant's IFC doesn't have gridlines, you will need to ask them to either reposition their model or to include gridlines.

 

Converting the IFC into Revit

To convert an IFC into Revit format there are two options:

  1. Open the IFC in Revit: File>Open>IFC (if you don't see the File menu try pressing  Ctrl+D)
  2. By linking the IFC: Open a new temporary project and link the (Insert>IFC). When linking an IFC file Revit will transform it to rvt format in the background and save it in the same location as the IFC.

In my experience, the second method is faster.

 

File preparation

If you selected the second method, close the temporary Revit file and open the rvt file generated by Revit. If you used the first method just continue working on the file.

Start by turning on the Project Base Point in a plan view. If the coordinates are 0, it isn't a good sign and the model probably is not using the proper coordinates. If there are coordinates in the Project Base Point note down the Northing, Easting and the Angle to True North

Next, place two gridlines in the Project Base Point:

 

You can now save the file and close it.


Linking the IFC

With your host model open, link the Revit file created in the previous steps.

Next, you need to locate the point of the coordinates that we got in the previous point. For doing that you can use the Survey Point by moving it to that point (type the coordinates into its properties). But first, make sure to unpin it and unclip it! Otherwise, you will move your project's coordinates. It is also a good idea to note down the coordinates of the current position of your survey point to be able o restore it.

Once you have moved your survey point, move your link so the gridline intersection that you created in the previous steps is in the survey point. After this, you can move your survey point back where it was and pin it.


Height and rotation

For adjusting the height I normally check the height above sea level of the lowest level. Then I move the link down by the same amount. This normally works fine.

If the rotation of the link doesn't match, I normally try using the Angle To True North that we noted down earlier and rotate the link by the same amount.


Final thoughts

As I mentioned at the beginning, dealing with IFC in Revit is not easy. Hopefully, these steps will help you link IFC files. I know other methods involve opening the IFC in a text editor and finding the coordinates. I find, however, that my method works and it is easier. If you want to share how you do it, please leave a comment.



Sunday, 24 October 2021

Purge Unused with the Revit API (Part 2: Materials)

In Part 1 we saw how to purge unused families with the PerformanceAdviser. In this part we'll see how to purge unused materials.

Purge Unused with the Revit API (Part 1)

In this entry, I will explain how to replicate the Purge Unused command using the Revit API. In the first part, I will explain how to delete all the unused families with the PerformanceAdviser.

Using this class, you cannot purge materials and material assets, so in Part 2, I will show you how to clean them.
 
You can find the Part 1 code below, along with comments explaining each part. Feel free to leave any questions or suggestions in the comments.


Wednesday, 23 December 2020

How to save custom colours in Revit

In this tutorial, I will show you how to save custom colour swatches in Revit so you can use them later.

  

Probably you are familiar with the Revit colour picker in the image above. The problem with this tool is that if you want to save a colour, you have to first select an empty square in the Custom Colors area, pick your colour on the colour picker and then click add. However, with this procedure, if you forget to click on an empty square first you will lose your colour when you click to try to save it as the colour will be reset to white.

The following trick will allow you to save colours even without selecting a square first. Note that in the image above, one of the squares has a dotted frame around it. The trick is to move the selection frame with the keyboard instead of the mouse. Follow these steps:

  1. Select the colour that you want in the colour picker.
  2. Press the TAB key to move the selection frame to the Custom Colors area.
  3. Select the custom square where you want to save your colour using the keyboard arrow keys.
  4. Click on the Add button with your mouse.

And that's it! the saved colours will be available in every colour selector in Revit.  

For clarity, check the video below:

Sunday, 13 December 2020

How to create a macro in Revit

  In this post, I will create a simple "Hello World" message just to demonstrate how to create and run macros in Revit.

Just follow these steps:

1- Open the Macro manager (Manage > Macro Manager)
 
 
2- Create a new Module:

  Modules are just a way of grouping macros. For example, in the image below I have a category with various tools, another one for tests and another one with tools for cleaning views.

There are two kinds of modules: project modules and application modules. The project modules are saved directly into the active document and will be available for all the team working in the model. However, it won't be available for other projects. The application modules will be only available for you but you will be able to use it in any project. My personal preference is to use application modules so I can reuse easily my macros. 

For this example, click on the Application tab and then on Create > Module. Give it a name, select C# and write a description (optional). Click OK and close the macro editor that will appear on the screen.

 
 
 
 3- Create a new macro:

  Now select your module (MyFirstMacro) and click on Create>Macro. Give it a name and a description (optional).

 
 
When you click OK, the macro editor will appear again with some code. But we are only interested in the part shown in the image below. Our code goes between the two curly brackets.
 
4-Write the code:
 Now write the following code between the curly brackets (I recommend that you write it instead of copy/paste):
 
TaskDialog.Show("My fisrt macro","Hello world!");
 
 Then just press the key F8 on your keyboard to build the macro.

5- Run the macro:
Select your macro in the macro manager and just click run.
 
 
 A message like in the image below should pop up:

 

Explanation of the code:

 The code in this tutorial is very simple but I will explain each part.

  

1-  public void HelloWorld(){}

This is how you define a method in C#. In this case, the method is the macro itself. A method in C# is a block of code that performs an action/s. The words "public" and "void" are properties of the method which I will explain in another post. The code of the method must go between the curly brackets.

2- TaskDialog

TaskDialog is a class of the Revit API. For the moment you can think of a class as a group of methods and properties. The TaskDialog class is used to create messages and dialogues for the user.

3- .Show("text 1","text 2")

"Show" is a method. The dot indicates that it belongs to the TaskDialog class. This method makes the dialog visible to the user. The first text in the brackets is the title of the dialog and the second one is the message itself. 

In future posts, I will explain how to create more complex macros.