When trying to begin a second transaction on a IFCStore, a NullReferenceException is thrown. My goal is to separate the classic IFC initialization (credentials, project, building) from the real “design” (adding beams, …).
To achieve this, I need to create separate transactions on the IFCStore I’m using.
- I create a transaction to add the project and building informations and commit
- I create a second transaction to add various elements. When creating this transaction, it fails. No details are given and I can’t debug it further than my code.
Here is a sample code :
public myIFCClass()
{
var credentials = CreateCredentials();
LocalIFCModel = IfcStore.Create(credentials, XbimSchemaVersion.Ifc4, XbimStoreType.InMemoryModel);
using (LocalIFCModel)
{
using (var txn = LocalIFCModel.BeginTransaction("Creating IFC"))
{
LocalIFCProject = InitializeProject(LocalIFCModel, "PROJECT : TEST");
LocalIFCBuilding = CreateBuilding(LocalIFCModel, LocalIFCProject, "BUILDING : TEST");
txn.Commit();
}
}
using (LocalIFCModel)
{
using (var txn = LocalIFCModel.BeginTransaction("Do something else")) // HERE !
{
// Do something else
txn.Commit();
}
}
}
Expected : beginning a second transaction shouldn’t cause any problems I guess.
I tried :
- Changing the transaction description
- Changing the transaction variable name
- Disposing the first transaction after its commit
- Using a model that’s not a class member
Enzo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.