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

One Thought on “xBim data investigation and export – Overarching #2

  1. David Marchant on 26/August/2014 at 06:27 said:

    I have been trying the second of your 2 examples in VisualStudio12 on a Windows 7 64-bit PC. Have copied your code exactly (except that my example file is different and slightly larger), and have done the NuGet package installation as per instructions. However, I get an EsentSessionSharingViolation error on the model.CreateFrom line. Is there a fix for this error?

    thanks

Leave a Reply to David Marchant Cancel reply

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

Post Navigation