Monthly Archives: March 2014

You are browsing the site archives by month.

xBim data investigation and export – Overarching #2


Where we explore the properties of an IFC file generated from Revit to get some information on room sizes.

Here’s the code used in the video:

static void Main(string[] args)
{
	using (XbimModel model = new XbimModel())
	{
		string ifcFile = "AreaTestWithProperties.ifc";
		string ifcLongFile = @"E:\Overarching\Videos\2014 02 - storey area\" + ifcFile;
		string xbimLongFile = System.IO.Path.ChangeExtension(ifcLongFile, "xbim");

		model.CreateFrom(
			ifcLongFile,
			xbimLongFile
			);

		model.Open(xbimLongFile, Xbim.XbimExtensions.XbimDBAccess.Read);

		//OBTER TODAS AS ENTIDADES DO MODELO
		var pisos = model.Instances.OfType<IfcBuildingStorey>();
		foreach (var piso in pisos)
		{
			Console.Write("Storey: {0}\r\n", piso.Name);
			IEnumerable<IfcRelDecomposes> decomp = piso.IsDecomposedBy;
			IEnumerable<IfcObjectDefinition> objs = decomp.SelectMany(s => s.RelatedObjects);
			IEnumerable<IfcSpace> spaces = objs.OfType<IfcSpace>();
			foreach (var space in spaces)
			{
				var area = space.GetGrossFloorArea();
				Console.Write("Space: {0} Area: {1}\r\n", space.Name, area.Value);
			}
		}
		model.Close();
	}
}

Link to:
Zip of exported sample IFC files

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: