XbimEssentials icon indicating copy to clipboard operation
XbimEssentials copied to clipboard

IO access exception saving store

Open theebow opened this issue 2 years ago • 1 comments

Hi team I had problem with this following code on V5.1.341 :

IfcStore::SaveAs is throwing a system.io.exception (can't access process, the process is already in use....)

            var myCredentials = new XbimEditorCredentials
            {
                ApplicationDevelopersName = "T",
                ApplicationFullName = "xBIM Toolkit",
                ApplicationIdentifier = "xTBIMKIT",
                ApplicationVersion = "1.0",
                EditorsFamilyName = "R",
                EditorsGivenName = "M",
                EditorsOrganisationName = "TSI"
            };

            try
            {
                IfcStore store = IfcStore.Create(filepath, myCredentials, XbimSchemaVersion.Ifc4);

                using (var txn = store.BeginTransaction("Create Project"))
                {
                    IfcProject myProject = store.Instances.New<IfcProject>();
                    myProject.GlobalId = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 23));
                    myProject.Initialize(ProjectUnits.SIUnitsUK);
                    myProject.UnitsInContext.SetSiLengthUnits(IfcSIUnitName.METRE, IfcSIPrefix.MILLI);
                    myProject.Name = "Debug export";

                    txn.Commit();
                }

                **store.SaveAs(filepath);**
            }
            catch (Exception ex)
            {
            }

after investigation, this one works :


            try
            {
                IfcStore store = IfcStore.Create(myCredentials, XbimSchemaVersion.Ifc4, Xbim.IO.XbimStoreType.InMemoryModel);

                using (var txn = store.BeginTransaction("Create Project"))
                {
                    IfcProject myProject = store.Instances.New<IfcProject>();
                    myProject.GlobalId = new Xbim.Ifc4.UtilityResource.IfcGloballyUniqueId(System.Guid.NewGuid().ToString().Replace("-", "").Substring(0, 23));
                    myProject.Initialize(ProjectUnits.SIUnitsUK);
                    myProject.UnitsInContext.SetSiLengthUnits(IfcSIUnitName.METRE, IfcSIPrefix.MILLI);
                    myProject.Name = "Debug export";

                    txn.Commit();
                }
                store.SaveAs(filepath, Xbim.IO.StorageType.Ifc);

            }
            catch (Exception ex)
            {
            }

For information the first code is an upgrade from one used with an older Xbim version Hope this will help you

best regards

theebow avatar Feb 23 '23 07:02 theebow

Thanks - will see if we can repro and get a fix in. Sounds like an EsentModel issue

andyward avatar Feb 23 '23 11:02 andyward