XbimEssentials icon indicating copy to clipboard operation
XbimEssentials copied to clipboard

Problem with IfcStore.Create: IfcSchemaVersion.Ifc4 "does not exist in the current context"

Open CamChatHel opened this issue 5 years ago • 1 comments

Hello, I have a beginner's question: I tried out the example on how to make a wall in IFC with xbim (https://docs.xbim.net/examples/proper-wall-in-3d.html). but I have some trouble running the code. "IfcSchemaVersion.Ifc4" gives me an error CS0103 does not exist in the curren tcontext. Also for the part "using Xbim.Common.Step21;" I get the notice that it is unecessary. I think this migth be part of the error. But I'm not sure. Has anyone an idea where the problem is? I think I installed all xbim-nuget-Packages that are needed, but maybe I missed something. Is there a list what is exactly needed? Is there another package I need that is not from xbim team? Thanks for your help!

 //....
// Only the part from the model where I have trouble:
private static IfcStore CreateandInitModel(string projectName)
        {
            
            var credentials = new XbimEditorCredentials
            {
                ApplicationDevelopersName = "xbim developer",
                ApplicationFullName = "Hello Wall Application",
                ApplicationIdentifier = "HelloWall.exe",
                ApplicationVersion = "1.0",
                EditorsFamilyName = "Team",
                EditorsGivenName = "xbim",
                EditorsOrganisationName = "xbim developer"
            };

            //----------- My problem is in this line: -----------
            var model = IfcStore.Create(credentials, IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel);

            using (var txn = model.BeginTransaction("Initialise Model"))
            {

                //create a project
                var project = model.Instances.New<IfcProject>();
                //set the units to SI (mm and metres)
                project.Initialize(ProjectUnits.SIUnitsUK);
                project.Name = projectName;
                txn.Commit();
            }
            return model;

        }






CamChatHel avatar Jul 13 '20 09:07 CamChatHel

Looks like the docs are slightly out of date. It should be XbimIfcSchemaVersion.Ifc4

If it helps, there's a full working version using the latest xbim packages over at https://github.com/xBimTeam/XbimSamples/blob/bb38c0facc9f17ae3eb5197991b0cf7e03b66537/HelloWall/HelloWallExample.cs#L158

andyward avatar Jul 13 '20 12:07 andyward