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 
Recent Comments