Hi there i am noob both C# and Xbim also. I am trying to get a values of some IFC objects and write it to a txt file.
I can get single values but i cant figure out how to get multiple values.
Here is my ugly code :)
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xbim;
using Xbim.Ifc;
using Xbim.Ifc4.Interfaces;
using ControlzEx.Standard;
namespace IFCMetadata
{
class Program
{
static void Main(string[] args)
{
const string fileName = @"D:\Mini.ifc";
using (var model = IfcStore.Open(fileName))
{
//get all doors in the model (using IFC4 interface of IfcDoor this will work both for IFC2x3 and IFC4)
var AllBeams = model.Instances.OfType<IIfcBeam>();
var AllColumns = model.Instances.OfType<IIfcColumn>();
var AllWelds = model.Instances.OfType<IIfcFastener>();
var ALLBolts = model.Instances.OfType<IIfcMechanicalFastener>();
List<string> Yazi = new List<string>();
foreach (var item in AllBeams)
{
var properties = item.IsDefinedBy
.Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
.SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
.OfType<IIfcPropertySingleValue>();
if (Yazi.Count>0)
{
Yazi.Add("$");
}
foreach (var property in properties)
{
// Console.WriteLine(property.Name + property.NominalValue);
Yazi.Add(property.Name +":"+ property.NominalValue);
// Yazi.Add($"Property: {property.Name}, Value: {property.NominalValue}");
}
}
foreach (var item in AllColumns)
{
var properties = item.IsDefinedBy
.Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
.SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
.OfType<IIfcPropertySingleValue>();
if (Yazi.Count > 0)
{
Yazi.Add("$");
}
foreach (var property in properties)
{
// Console.WriteLine(property.Name + property.NominalValue);
Yazi.Add(property.Name + ":" + property.NominalValue);
// Yazi.Add($"Property: {property.Name}, Value: {property.NominalValue}");
}
}
foreach (var item in AllWelds)
{
var properties = item.IsDefinedBy
.Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
.SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
.OfType<IIfcPropertySingleValue>();
if (Yazi.Count > 0)
{
Yazi.Add("$");
}
foreach (var property in properties)
{
// Console.WriteLine(property.Name + property.NominalValue);
Yazi.Add(property.Name + ":" + property.NominalValue);
// Yazi.Add($"Property: {property.Name}, Value: {property.NominalValue}");
}
}
foreach (var item in ALLBolts)
{
var properties = item.IsDefinedBy
.Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
.SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
.OfType<IIfcPropertySingleValue>();
if (Yazi.Count > 0)
{
Yazi.Add("$");
}
foreach (var property in properties)
{
// Console.WriteLine(property.Name + property.NominalValue);
Yazi.Add(property.Name + ":" + property.NominalValue);
// Yazi.Add($"Property: {property.Name}, Value: {property.NominalValue}");
}
}
var yaziliste = Yazi.ToArray();
File.WriteAllLines(@"d:\Mini.txt", yaziliste);
}
}
}
Hi there i am noob both C# and Xbim also. I am trying to get a values of some IFC objects and write it to a txt file.
I can get single values but i cant figure out how to get multiple values.
Here is my ugly code :)
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xbim; using Xbim.Ifc; using Xbim.Ifc4.Interfaces; using ControlzEx.Standard;
namespace IFCMetadata { class Program { static void Main(string[] args) { const string fileName = @"D:\Mini.ifc";
}