Skip to content

Merge Multiple IFC Files  #588

Open
Open
@ShehabFekry

Description

@ShehabFekry

I have multiple IFC files with

Xbim.Essentials 4.0.29

`using (var model1 = IfcStore.Open(@"E:\2218-ATA-TRK-ZZZ-2DM-AR-2218-ATA-B01-ZZZ-MOD-AR.ifc"))
{
// Load the second IFC file
using (var model2 = IfcStore.Open(@"E:\2218-ATA-TRK-ZZZ-2DM-AR-2218-ATA-B02-ZZZ-MOD-AR.ifc"))
{
// Create a new IFC store for the merged model
using (var mergedModel = IfcStore.Create(XbimSchemaVersion.Ifc2X3, Xbim.IO.XbimStoreType.InMemoryModel))
{
using (var transaction = mergedModel.BeginTransaction("Merging IFC Files"))
{
var mappings1 = new XbimInstanceHandleMap(model1, mergedModel);
var mappings2 = new XbimInstanceHandleMap(model2, mergedModel);
var instances = model1.Instances.ToList();
// Copy all entities from the first model
int counter = 0;
foreach (var entity in model1.Instances.ToList())
{
if (entity.EntityLabel >= 22 && entity.EntityLabel <= 28) { continue; }
mergedModel.InsertCopy(entity, mappings1, null, true, false);
counter++;
}

            foreach (var entity in model2.Instances.ToList())
            {
                mergedModel.InsertCopy(entity, mappings2, null, true, false);
            }

            // Commit the transaction
            transaction.Commit();
        }

        // Save the merged model to a new file
        mergedModel.SaveAs(@"E:\merged.ifc");
    }
}

}`

Expected behavior:

What would you expect to happen

I expect all entities from both models to be placed in the new model.

What actually is happening
The entities take in the foreach loop some entities take a very long time to be placed entities like IFCGEOMETRICREPRESNTATIONSUBCONTEXT('Axis') .. etc

in the screen shot entities with label 22 to 26

Screenshot 2024-11-18 161948

why do they take all this time? and what should i do to increase the speed of the plugin to merge multiple ifc files?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions