xBimTeam / XbimEssentials

A .NET library to work with data in the IFC format. This is the core component of the Xbim Toolkit
https://xbimteam.github.io/
Other
485 stars 172 forks source link

[Question] How to use IfcRepresentation from original IFC file in newly created IFC file #489

Open milojevicA opened 1 year ago

milojevicA commented 1 year ago

Hi, I'm trying to keep original IfcRepresentation from IFC file in my newly exported file.

I tried to use InsertCopy, but it throws an Exception ("Cross model entity assignment"). InsertCopy copies Entity Tags also, and I think that is a problem also.

Is it possible to do use that original entities to create entities with all sub-entites, but with new Entity Tags?

martin1cerny commented 1 year ago

This exception is thrown when you try to assign entity from model A to a property of entity from model B. I assume that by Entity Tags you mean IPersistEntity.EntityLabel? If that is the case, then there is an option to use new entity labels for the copied entities. That is why you need to use the entity map in InsertCopy, so we know which entities from model A are copies of which entities in model B to avoid graph expansion and potential infinite insertion loops.

Make sure you always only assign entities within one model.