Closed seghier closed 9 months ago
Hi How can we retrieve the material name from an IFC file?
In this code i try o.Material, obj.Material but the result always empty
o.Material, obj.Material
private void PrintHierarchy(IIfcObjectDefinition o, int level, DataTable resultTable) { var newRow = resultTable.NewRow(); newRow["Name"] = o.Name; newRow["Type"] = o.GetType().Name; newRow["Level"] = level; // Check if the object is an IIfcObject and cast it to access its properties if (o is IIfcObject obj) { newRow["Description"] = GetPropertyValue(obj, "Description"); newRow["EntityLabel"] = obj.EntityLabel.ToString(); newRow["Guid"] = obj.GlobalId.ToString(); newRow["OwnerHistory"] = GetPropertyValue(obj, "OwnerHistory"); } else { newRow["Description"] = "N/A"; newRow["EntityLabel"] = "N/A"; newRow["Guid"] = "N/A"; newRow["OwnerHistory"] = "N/A"; } resultTable.Rows.Add(newRow); var spatialElement = o as IIfcSpatialStructureElement; if (spatialElement != null) { foreach (var containedElement in spatialElement.ContainsElements) { foreach (var element in containedElement.RelatedElements) { PrintHierarchy(element, level + 1, resultTable); } } } foreach (var item in o.IsDecomposedBy.SelectMany(r => r.RelatedObjects)) { PrintHierarchy(item, level + 1, resultTable); } }
Hi How can we retrieve the material name from an IFC file?
In this code i try
o.Material, obj.Material
but the result always empty