xBimTeam / XbimCobieExpress

XbimCOBieExpress is a library to manage COBie data in a similar way that Xbim.Essentials does for IFC data
Other
12 stars 8 forks source link

IFC file to COBie #15

Closed FMD2021 closed 1 year ago

FMD2021 commented 3 years ago

I'm trying to run a simple code based on the examples provided. In detail, I want to be able to export an IFC file to COBie format. However, I'm having issues with these lines:

`var cobie = new CobieModel();

        using (var txn = cobie.BeginTransaction("IFC to COBie transaction"))
        {
            var exchanger = new IfcToCoBieExpressExchanger(ifc, cobie);
            exchanger.Convert();
            txn.Commit();
        }`

Both CobieModel() and IfcToCoBieExpressExchanger(ifc, cobie) are not being detected.

Here is the overall script: `using System; using System.Windows.Forms; using Xbim.Ifc; using System.IO; using Xbim.IO.Memory; using XbimExchanger.IfcToCOBieExpress;

namespace IFC_to_COBie { public partial class Form1 : Form { private string fileName; private XbimEditorCredentials editor;

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        OpenFileDialog dialog = new OpenFileDialog();
        dialog.ShowDialog();
        string filename = dialog.FileName;
        if (filename == "")
            return;

        var ifc = MemoryModel.OpenReadStep21(fileName);

        var cobie = new CobieModel();

        using (var txn = cobie.BeginTransaction("IFC to COBie transaction"))
        {
            var exchanger = new IfcToCoBieExpressExchanger(ifc, cobie);
            exchanger.Convert();
            txn.Commit();
        }

        // We can persists our model to disk for faster access in future
        var output = Path.ChangeExtension(fileName, ".cobie");
        cobie.SaveAsEsent(output);

        textBox1.Text = "A new COBie was created";
    }

} ` image

I'm pretty new to XBIM, so any help would be appreciated.

Thank you.

andyward commented 3 years ago

It sounds like you're missing some project references. E.g. it sounds like you're missing a reference to Xbim.CobieExpress

What does your csproj look like?

FMD2021 commented 3 years ago

It sounds like you're missing some project references. E.g. it sounds like you're missing a reference to Xbim.CobieExpress

What does your csproj look like?

I tried to add the reference, but with no success. The erros persist. My csproj looks like this:

image

image

`using System; using System.Windows.Forms; using Xbim.Ifc; using System.IO; using Xbim.IO.Memory; using XbimExchanger.IfcToCOBieExpress; using Xbim.CobieExpress;

namespace IFC_to_COBie { public partial class Form1 : Form { private string fileName; private XbimEditorCredentials editor;

      public Form1()
      {
          InitializeComponent();
      }

      private void button1_Click(object sender, EventArgs e)
      {
          OpenFileDialog dialog = new OpenFileDialog();
          dialog.ShowDialog();
          string filename = dialog.FileName;

          if (filename == "")
              return;

          var editor = new XbimEditorCredentials
          {
              ApplicationDevelopersName = "Some Name",
              ApplicationFullName = "Some Name",
              ApplicationIdentifier = "0001",
              ApplicationVersion = "4.0",
              //your user
              EditorsFamilyName = "Some Name",
              EditorsGivenName = "Some Name",
              EditorsOrganisationName = "Name of work place"
          };

          var ifc = MemoryModel.OpenReadStep21(fileName);

          var cobie = new CobieModel();

          using (var txn = cobie.BeginTransaction("IFC to COBie transaction"))
          {
              var exchanger = new IfcToCoBieExpressExchanger(ifc, cobie);
              exchanger.Convert();
              txn.Commit();
          }

          var output = Path.ChangeExtension(fileName, ".cobie");
          cobie.SaveAsEsent(output);

          textBox1.Text = "A new COBie was created";
      }

      private void Form1_Load(object sender, EventArgs e)
      {

      }
  }

}`

Thank you.

andyward commented 3 years ago

You need to fix your package references. The yellow warning signs on the packages will probably tell you what the issue is.

If you still can sort it, why don't you just share a repo with your test project? Really we need to see _IFC_ToCOBie.csproj