Interested to see what we do in the cloud? Join us for one of our webinars!

Federation of multiple models

using System;
using Xbim.Common.Step21;
using Xbim.Ifc;
using Xbim.Ifc4.Interfaces;

namespace BasicExamples
    public class FederationExample
        public void CreateFederation()
            var editor = new XbimEditorCredentials
                ApplicationDevelopersName = "You",
                ApplicationFullName = "Your app",
                ApplicationIdentifier = "Your app ID",
                ApplicationVersion = "4.0",
                //your user
                EditorsFamilyName = "Santini Aichel",
                EditorsGivenName = "Johann Blasius",
                EditorsOrganisationName = "Independent Architecture"
            using (var federation = IfcStore.Create(editor, IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel))

                federation.AddModelReference("SampleHouse.ifc", "Bob The Builder", "Original Constructor"); //IFC4
                federation.AddModelReference("SampleHouseExtension.ifc", "Tyna", "Extensions Builder"); //IFC2x3

                Console.WriteLine($"Model is federation: {federation.IsFederation}");
                Console.WriteLine($"Number of overall entities: {federation.FederatedInstances.Count}");
                Console.WriteLine($"Number of walls: {federation.FederatedInstances.CountOf<IIfcWall>()}");
                foreach (var refModel in federation.ReferencedModels)
                    Console.WriteLine($"    Referenced model: {refModel.Name}");
                    Console.WriteLine($"    Referenced model organization: {refModel.OwningOrganisation}");
                    Console.WriteLine($"    Number of walls: {refModel.Model.Instances.CountOf<IIfcWall>()}");


                //you can save information about the federation for a future use

Console output will look like this:

Model is federation: True
Number of overall entities: 50303
Number of walls: 8

    Referenced model: SampleHouse.ifc
    Referenced model organization: Bob The Builder
    Number of walls: 5

    Referenced model: SampleHouseExtension.ifc
    Referenced model organization: Tyna
    Number of walls: 3

Federation settings saved as IFC file look like this. This convention is purely our invention so it won't work with other tools. But it will allows you to create federations in your system and reopen them again once needed.

FILE_DESCRIPTION ((''), '2;1');
FILE_NAME ('', '2016-10-27T13:14:43', (''), (''), 'Xbim File Processor version', 'Xbim version', '');
#1=IFCACTORROLE(.USERDEFINED.,'Original Constructor',$);
#2=IFCORGANIZATION($,'Bob The Builder',$,(#1),$);
#4=IFCACTORROLE(.USERDEFINED.,'Extensions Builder',$);

Want to stay updated on xbim news and developments?

Sign up for a newsletter

Some of the companies using xbim toolkit:

xbim ltd.