This is part 4 of a series of posts about getting BIM data into Unity.
We discussed ArchiCAD in a previous article, but this time, we look at Revit. Getting our information into a schedule is not difficult, but getting the identifier of the elements is actually not trivial at all. We need to do some mean tweaking and we need a Revit Add-on too…
Preparing Revit Schedules for use with Unity
Basic concept: We will collect information from our BIM model into a table (schedule) for export. If we add the ID of the element in the first column, we can use that information to map the data from the table to the entity.
Creating an instance-parameter for the Entity ID
In Revit, every entity has a unique number, the EntityID. While it looks very simple, there is a catch. It can be used directly from the Application’s Programming Interface (API) and you can also query objects for it in the Revit GUI, but there is no way to collect them in a schedule (in contrast to ArchiCAD, I must say)!
There is a workaround, which can be also be automated:
- Use a Shared or Project Parameter to store the unique Revit Entity ID (and possibly the IFC Guid)
- Step through all objects to collect both IDs and write them into the Parameter
- Set up a Schedule including these IDs and our required parameters
The first step is easy to accomplish and is widely documented. There are reasons for Shared and Project parameters, but both are possible and both can be scheduled, so it doesn’t really matter too much.
Here I’ve used a Project Parameter and defined it as an Integer. It is very important to ensure it sits at Instance Level and not Type Level! You may check All Elements or only those you want to have the ID.
Getting the Entity ID into an instance-parameter
The field is now prepared, but is still empty.
However, writing the ID into this field manually is not what you want to do, ever… So we need some automation.
The most extensive solution is to develop a small Add-on for Revit, which runs through all elements and collects the EntityID. Its value can then be copied in the shared parameter. This can also be done with the IFCguid.
Luckily for us, there is a free Add-on that you can use to automate adding the EntityID to the object parameters, so they can be scheduled after all.
The Show ID add-in precisely does that.
The installation of the plug-in is straight-forward. It then becomes available in the Add-ins tab and the plug-in opens in a very simple dialog. You can apply it to ALL elements or only to the selected ones.
However, there are some caveats. This assumes that all these elements are editable. In collaborative projects, they may sit inside a locked WorkSet. And in the background, this approach does create a Shared Parameter without asking for it, so beware if you are sensitive about your setup.
The second approach is more fun, though, if you want to dive into Visual Programming with Dynamo. There the process is surprisingly simple. The only gotcha is that you’d best prepare the parameter to store the ID.
In Dynamo, you need only a few Nodes. In the example below, I was just interested in adding the Element ID into the Rooms. So I used a Categories Node to define the Rooms and an “All Elements of Category” to make the actual selection/query. They both live under the Selection header.
We can then request the ID from the Element (Element header) and link the elements to this node.
Finally, the Element.SetParameterByName does the hard work of filling the parameter with the values (IDs). You can add a small String node to define the Parameter Name.
For larger projects, it is best to have this Dynamo definition not run automatically.
No matter which approach you use, you should end up with the EntityID and (possibly) the IFC Guid as instance-parameters to all Revit objects.
Create the Schedule in Revit
Create either a multi-schedule for many different element types or create separate schedules for walls, slabs, doors and windows to add more specific parameters to the list. All the effort above was meant to be able to add the “Element ID” field alongside element parameters into the schedule.
It may be best to have a few schedules, for the different object categories you want to tackle, e.g. Walls, Slabs etc.
Check that the Element ID is included in the schedule:
Now you can export the schedule to a CSV file. We use “;” as a list separator and double quotes as string delimiters and also avoid to add the title and (sub-)totals, but be sure to add the Headers.
Make a few more, e.g. for Slabs, Roofs, Columns etc… This is now straightforward.
Beware that this is still a simple Integer Field but as long as you remember to re-run the Script when new elements are introduced, you should be fine.
With these schedules in place, we are now ready to tackle the next task: getting this data in our interactive model.
See you next time!
Comments
Post a Comment