public void CreateFederation() { using (var fedModel = Xbim.Ifc2x3.IO.XbimModel.CreateTemporaryModel()) { fedModel.Initialise("Federation Creating Author", "Federation Creating Organisation", "This Application", "This Developer", "v1.1"); using (var txn = fedModel.BeginTransaction()) { fedModel.IfcProject.Name = "Federation Project Name"; txn.Commit(); } //now add federated models fedModel.AddModelReference(ModelA, "The Architects Name", IfcRoleEnum.ARCHITECT); fedModel.AddModelReference(ModelB, "The Owners Name", IfcRoleEnum.BUILDINGOWNER); // fedModel.AddModelReference(ModelC, "The Cost Consultants Name", IfcRole.UserDefined, "Cost Consultant"); fedModel.SaveAs("Federated Model", IfcStorageType.Ifc); } //close and automatically delete the temporary database //Now open the Ifc file and see what we have using (var fed = new Xbim.Ifc2x3.IO.XbimModel()) { fed.CreateFrom("Federated Model.ifc", "Federated Model.xBIMF"); //use xBIMF to help us distinguish fed.Open("Federated Model.xBIMF"); //check the various ways of access objects give consistent results. var localInstances = fed.Instances.Count; var totalInstances = fed.FederatedInstances.Count; long refInstancesCount = 0; foreach (var refModel in fed.ReferencedModels) { refInstancesCount += refModel.Model.Instances.Count; } Assert.IsTrue(totalInstances == refInstancesCount + localInstances); long enumeratingInstancesCount = 0; foreach (var item in fed.FederatedInstances) { enumeratingInstancesCount++; } Assert.IsTrue(totalInstances == enumeratingInstancesCount); long fedProjectCount = fed.FederatedInstances.OfType <IfcProject>().Count(); long localProjectCount = fed.Instances.OfType <IfcProject>().Count(); Assert.IsTrue(fedProjectCount == 3); Assert.IsTrue(localProjectCount == 1); } }
public static XbimModel CreateTemporaryModel() { var tmpFileName = Path.GetTempFileName(); try { var model = new XbimModel(); model.CreateDatabase(tmpFileName); model.Open(tmpFileName, XbimDBAccess.ReadWrite, true); model.Header = new StepFileHeader(StepFileHeader.HeaderCreationMode.InitWithXbimDefaults); foreach (var schemasId in model.Factory.SchemasIds) { model.Header.FileSchema.Schemas.Add(schemasId); } return(model); } catch (Exception e) { throw new XbimException("Failed to create and open temporary xBIM file \'" + tmpFileName + "\'\n" + e.Message, e); } }
public void ValidIdentityInFederation() { using (var fedModel = Xbim.Ifc2x3.IO.XbimModel.CreateTemporaryModel()) { fedModel.Initialise("Federation Creating Author", "Federation Creating Organisation", "This Application", "This Developer", "v1.1"); using (var txn = fedModel.BeginTransaction()) { fedModel.IfcProject.Name = "Federation Project Name"; txn.Commit(); } //now add federated models fedModel.AddModelReference(ModelFedP1, "The Architects Name", IfcRoleEnum.ARCHITECT); fedModel.AddModelReference(ModelFedP2, "The Owners Name", IfcRoleEnum.BUILDINGOWNER); fedModel.SaveAs("P1P2Federation", IfcStorageType.Ifc); } //close and automatically delete the temporary database //Now open the Ifc file and see what we have using (var fed = new Xbim.Ifc2x3.IO.XbimModel()) { fed.CreateFrom("P1P2Federation.ifc", "P1P2Federation.xBIMF"); //use xBIMF to help us distinguish fed.Open("P1P2Federation.xBIMF"); fed.EnsureUniqueUserDefinedId(); var mustDiffer = fed.FederatedInstances.OfType <IfcGeometricRepresentationSubContext>() .Where(x => x.ContextIdentifier == @"Body").ToArray(); // we are expecting two items (one body from each model loaded) // they happen to share the same entitylabel, but they have different models. var first = mustDiffer[0]; var second = mustDiffer[1]; Assert.IsFalse(first == second); var tst = new HashSet <IfcGeometricRepresentationContext>(); tst.Add(first); tst.Add(second); Assert.IsTrue(tst.Count == 2); } }
public XbimModelSummary(XbimModel model) { _model = model; }