Comparing two ifc models
Hello! I've been trying to find any way to properly compare two ifc models, but couldn't find a way to do this. So is it possible to do using xbim? Thanks!
Yes, this is possible to do with xbim. You are asking in the WebUI project so, are you interested in the visualization of the comparison, or the actual comparison of models?
I dont actually need to visuilize the result of the comparisson as i've created this question here by mistake. My bad. I need to compare two ifc models and find the difference between them and then save this difference. So this should be some kind of versioning. I know that i can compare the text of this models, but this approach doesn't seem reliable for me. Maybe i'm wrong about it. How can I compare them?
Hi @Kirill-basic, this is a pretty complex problem. I've had some experience on doing it in the past, and it depends largely on the purpose that you are comparing models for.
Can you say more about the background?
Xbim doesn't have any "single line" comparison code, but will allow you to implement the comparison strategy of your choice. There are several aspects to consider:
- Globally unique ID (GUID): Every class inheriting from IfcRoot has GUID. Exporting SW should keep these stable when re-exporting the model. This is obviously only possible if the authoring SW has this concept. It is also tricky for elements which authoring SW is creating on the fly. While it works for most of the data, SW identity can only be used to detect added & deleted root entities. It doesn't tell you if the entity has changed.
- Geometry and position: You may want to check position and/or geometry if you consider changed placement or geometry to be the change
- Material: You may want to check if material has changed
- Properties & quantities: There is a reason why properties are associated with elements using IfcRelDefines. Properties often form part of the element definition. Therefore changed property might be the change. You may also only want to watch certain properties based on your usecase.
- Connectivity:: Is the element is part of a connected set of elements, changing this connectivity might be the change.
There are other relations you may want to check. Also, if the element has different ID, but has the same placement, geometry, properties etc - do you consider it to be added or changed? Or is it just new element?
So, it all depends on your usecase. In other words - what do you consider to be the change. As I said, once you identify what is important for you , you can use xbim Toolkit to analyse two models and find all new, changed and deleted entities.
Can you say more about the background?
Hello! I'm working on a project that should be using ifc files. Now I need to create some sort of versioning of files. For example user creates a model and the saves this model. Then he opens this file again and makes some changes (e.g. adds new window or moves the old one) and saves it again. In order to save different versions of this model and not to use too much memory i want to fidn the difference between this versions of the model and then save only the changed part of it (only the difference, no matter how to store this difference). I know that some people realized comparing the lines of the ifc file but i'm not sure that it works properly. So i want to know what is the best way to do it and maybe get some help on how I can do this
Comparing lines of text in IFC is not a good idea as the order and the number at the beginning of the line (we call it entity label) is not stable. Even two consecutive exports might easily be different. Saying so, it might be enough if your concern is to optimise the storage by storing the diff only. If you need to understand the change, it is far more complex.
Martin is quite right. If you want to get some improvements on the consistency an option would be to pre-process files before comparison so that the entity label is generated from the information in the entity, hence consistent. There are clash-risks in doing this, but I've found empirically that they are tolerable. Many more small adjustments to lists, sorting of entities and splitting of files can make the diff quite small.
Having said this, if you're doing it just for saving storage if feels like overkill. Just work carefully with compression.
Thanks! I'll take it into consideration. And some more info about my task. I need to store information about geometry only. So i dont need any info on the materials and other things.
I need to store information about geometry only.
Depending on the context, you might be better off comparing the triangulated mesh, then.
I need to store information about geometry only.
Depending on the context, you might be better off comparing the triangulated mesh, then.
Ok. and still comparing text is not a good idea right?
As always... it depends.
You could develop a text format that stores geometry in a single text line for each mesh, attached to the guid of the product rather than the entity label.
At that point a standard text diffing method might be efficient.
Ok. Now I think it's pretty clear to me. Thank you very much!
While it may be in need of an update, there's an example of how you might do this here: https://github.com/xBimTeam/XbimAnalysis/blob/master/Xbim.Analysis/VersionComparison.cs
It's not exactly XBim, but perhaps you might like the IFCDiff tool part of IfcOpenShell?