Open joselaks opened 4 years ago
Hi Jose,
you want something like:
using Xbim.Ifc4.Interfaces;
using (var model = IfcStore.Open(filename))
{
var allWalls = model.Instances.OfType<IIfcWall>(); // All items of type IIfcWall
foreach (var item in allWalls)
{
//Read the surface, volume, etc....
}
}
But be sure to take a look at https://docs.xbim.net/examples/using-linq-for-optimal-performance.html
Hi Andy Thanks for the reply! To find out the length and width of the walls I use this code. Is there something more efficient?
using (var model = IfcStore.Open(filename))
{
var allWalls = model.Instances.OfType(); // All items of type IIfcWall
foreach (var item in allWalls)
{
var longitudes = item.IsDefinedBy
.SelectMany(r => r.RelatingPropertyDefinition.PropertySetDefinitions)
.OfType()
.SelectMany(qset => qset.Quantities)
.OfType();
if (longitudes.Count() != 0)
{
var ancho = longitudes.FirstOrDefault(a => a.Name == "Width");
var alto = longitudes.FirstOrDefault(a => a.Name == "Height");
}
}
}
Best Regards, José
Hello @joselaks, you will find that different models store the information that you are looking for in inconsistent ways, it's better to have a look at a bunch of models before you use any code similar to this in production. Otherwise this seems to work. Best, Claudio
I am very enthusiastic about xBIM! I am trying to make a code that reads the walls and obtains from each one of them the physical dimensions (surface, volume, etc). I got here but cannot include code that reads it inside the "foreach" ... how do I do it?
Thank you !