First steps with xBIM – Overarching #1

Where we introduce xBIM and present the first steps for you to start developing with it.

During the tutorial you will need the the following bit of code, copy and paste it from here to the development environment.

OpenFileDialog dialog = new OpenFileDialog();
dialog.ShowDialog();
string filename = dialog.FileName;
if (filename == "")
	return;

System.IO.File.Delete("temp.xbim");
Xbim.IO.XbimModel m = new Xbim.IO.XbimModel();
m.CreateFrom(filename, "temp.xbim");
m.Close();

m.Open("temp.xbim", Xbim.XbimExtensions.XbimDBAccess.Read);
var allwalls = m.Instances.OfType();
textBox1.Text = allwalls.Count().ToString();

Links of the resources used in the video:

One Thought on “First steps with xBIM – Overarching #1

  1. Pantelitsa Mavrovounioti on 12/March/2015 at 21:19 said:

    Hi,

    I did the tutorial and I run it with a success but I tried to do it by opening 2 IFC files and try to compare it starting by simply counting both model’s walls and if they have the same number of walls the program will say if they are the same or not.

    I tried to do it by adding 1 more button with the same code but changing any variable to number 2 (eg. m2, allwalls2 etc.)

    Moreover, instead of textBox1.Text = allwalls.Count().ToString();
    I did this:
    int building =0;
    :
    :
    building1 = allwalls1.Count();
    textBox1.Text = “1st building has ” + building1 + ” walls \n\r”;

    Opening the 1st file the output is ok.
    But when I open the 2nd file the programm crashes and this warning/error appears on
    “System.IO.File.Delete(“temp.xbim”);”
    “A first chance exception of type ‘System.IO.IOException’ occurred in mscorlib.dll”

    I tried to solved it using for loops, if statements, put it in different orders but still have the same error.

    So what is the use of “System.IO.File.Delete(“temp.xbim”);”, do we need it in the code? How can I solve the problem?

    Thank you!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation