Code Monkey home page Code Monkey logo

xbimessentials's Introduction

Branch Build Status MyGet NuGet
Master Build Status master
Develop Build Status -
Toolkit Component Latest Myget (develop) Latest Myget (master) Latest Nuget
Essentials develop master Nuget
Geometry develop master Nuget
CobieExpress develop master Nuget
Windows UI develop master Nuget
Exchange develop master Nuget

XbimEssentials

XbimEssentials is the foundational components of Xbim, the eXtensible Building Information Modelling toolkit for the .NET platform. This library enables software developers to easily read, write, validate and interrogate data in the buildingSmart IFC formats, using any .NET language.

As of version 6.0 XbimEssentials includes support for .netstandard2.0, .netstandard2.1 and .net6.0. Supporting netstandard2.0 provides support .NET Framework 4.7.2 upwards. Earlier .NET Framewaork versions may work, but we can't provide any support for them.

Background / Motivation

IFC is an ISO Standard and platform-neutral open file format for data exchange of building information. This library supports STEP, IfcXml and IfcZip formats, and enables you to read and write the full schema of IFC2x3 and IFC4 (including support for the latest Ifc4 Addendum 2).

The wider XBIM toolkit contains additional repositories with libraries to read and write related Open BIM formats including COBie and BIM Collaboration Format (BCF)

In order to visualise 3D Geometries you will need to include the Xbim.Geometry package which provides full support for geometric, topological operations and visualisation.

The motivation behind XbimEssentials is to take away much of the complexity and 'heavy lifting' required to read and write OpenBIM file formats, so you can focus on creating software solutions without needing deep understanding of STEP/Express parsing, 3D graphics - enabling you to work at a higher level than the buildingSmart data model.

Updating from prior versions

Please see our ChangeLog for details on what's new and what you need to upgrade. In particular, please note the following section copied here:

BREAKING CHANGE: V6 implements a new mechanism for discovering internal resources and uses standard (.net Dependency Injection patterns)[https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection] for managing services internally. Xbim.Common now introduces an internal DI service that you can optionally integrate with your own DI implementation, for providing Logging services, and configuring xbim service behaviour. E.g. Invoking: XbimServices.Current.ConfigureServices(s => s.AddXbimToolkit(opt => opt.UseMemoryModel().UseLoggerFactory(yourloggerFactory))); registers the Toolkit internal dependencies, uses an In-memory model and inserts your configured ILoggerFactory into the service in place of our default one.IfcStore.ModelProviderFactoryhas been deprecated as this is provided for by the above mechanism The persistent EsentModel is now available automatically through IfcStore (on Windows) so there is no need for theUseHeuristicModelProvider()` 'ceremony' to ensure Esent is used. Note: The default Logging implementation has been removed from Toolkit to reduce the amount of dependencies. To enable is a simple matter of adding logging to the Xbim Services. See (Example)[

public void Logging_can_be_added()
]

Code Examples

If you want to jump straight in we have some examples on our docs site. But here's a 60 second tour of reading and writing:

1. Reading data

Given an IFC File SampleHouse.ifc exported from a tool such as Revit, this is a simple example showing how you'd read and extract data, using LINQ:

const string fileName = "SampleHouse.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 allDoors = model.Instances.OfType<IIfcDoor>();

    // get only doors with defined IIfcTypeObject
    var typedDoors = model.Instances.Where<IIfcDoor>(d => d.IsTypedBy.Any());

    // get one single door by its unique identifier / guid
    var id = "2AswZfru1AdAiKfEdrNPnu";
    var theDoor = model.Instances.FirstOrDefault<IIfcDoor>(d => d.GlobalId == id);
    Console.WriteLine($"Door ID: {theDoor.GlobalId}, Name: {theDoor.Name}");

    // get all basic properties of the door
    var properties = theDoor.IsDefinedBy
        .Where(r => r.RelatingPropertyDefinition is IIfcPropertySet)
        .SelectMany(r => ((IIfcPropertySet)r.RelatingPropertyDefinition).HasProperties)
        .OfType<IIfcPropertySingleValue>();
    foreach (var property in properties)
        Console.WriteLine($"Property: {property.Name}, Value: {property.NominalValue}");
}

... resulting in output like:

Door ID: 3cUkl32yn9qRSPvBJVyWYp, Name: Doors_ExtDbl_Flush:1810x2110mm:285860
Property: IsExternal, Value: true
Property: Reference, Value: 1810x2110mm
Property: Level, Value: Level: Ground Floor
Property: Sill Height, Value: 0
Property: Area, Value: 4.9462127188431
Property: Volume, Value: 0.193819981582386
Property: Mark, Value: 1
Property: Category, Value: Doors
Property: Family, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Family and Type, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Head Height, Value: 2110
Property: Host Id, Value: Basic Wall: Wall-Ext_102Bwk-75Ins-100LBlk-12P
Property: Type, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Type Id, Value: Doors_ExtDbl_Flush: 1810x2110mm
Property: Phase Created, Value: New Construction

2. Amending data

In this simple example we're going to add a 'purchase cost' property to a single Door. We could have applied the cost against the Door Type if all instances of it shared the property.

const string fileName = "SampleHouse.ifc";
var editor = new XbimEditorCredentials
{
    ApplicationDevelopersName = "EZ Bim Apps Inc",
    ApplicationFullName = "My BIM App",
    ApplicationIdentifier = "my-bim-app",
    ApplicationVersion = "1.0",
    EditorsFamilyName = "John",
    EditorsGivenName = "Doe",
    EditorsOrganisationName = "Acme Consultants Inc"
};

using (var model = IfcStore.Open(fileName, editor, true))
{
    // get an existing door from the model
    var id = "3cUkl32yn9qRSPvBJVyWYp";
    var theDoor = model.Instances.FirstOrDefault<IfcDoor>(d => d.GlobalId == id);

    // open transaction for changes
    using (var txn = model.BeginTransaction("Doors modification"))
    {
        // create new property set to host properties
        var pSetRel = model.Instances.New<IfcRelDefinesByProperties>(r =>
        {
            r.GlobalId = Guid.NewGuid();
            r.RelatingPropertyDefinition = model.Instances.New<IfcPropertySet>(pSet =>
            {
                pSet.Name = "Commercial";
                pSet.HasProperties.Add(model.Instances.New<IfcPropertySingleValue>(p =>
                {
                    p.Name = "PurchaseCost";
                    p.NominalValue = new IfcMonetaryMeasure(200.00); // Default Currency set on IfcProject
                }));
            });
        });

        // change the name of the door
        theDoor.Name += "_costed";
        // add properties to the door
        pSetRel.RelatedObjects.Add(theDoor);

        // commit changes
        txn.Commit();
    }
}

3. Generating Geometry

We need to generate geometry from the IFC primitives before you can visualise the 3D model. This essentially produces a tesselation/mesh that can be fed into a 3D graphics card, typically via some Graphics Library (OpenGL, DirectX, WebGL etc)

Note: Generating the 3D Geometry requires the Xbim.Geometry package which is currently only supported on a Windows platform. This utililises a native geometry engine to handle boolean operations / CSG

Since this process can take some seconds / minutes for larger models, and can consume significant computation resource, it's common to do the geometry generation once and store in the xbim database format for future use.

For web-based visualisation an alternative is to output geometry to the wexbim format, which is optimised for web delivery in a browser using Xbim.WebUI

const string fileName = @"SampleHouse4.ifc";
var wexBimFilename = Path.ChangeExtension(fileName, "wexBIM");
var xbimDbFilename = Path.ChangeExtension(fileName, "xBIM");
	
using (var model = IfcStore.Open(fileName))
{
	// IFC file is already parsed and open. Now build the 3D
	var context = new Xbim3DModelContext(model);
	context.CreateContext();	// Creates the Geometry using native GeometryEngine

	// Optional: Export to 'wexbim' format for use in WebUI's xViewer - geometry only
	using (var wexBimFile = File.Create(wexBimFilename))
	{
		using (var wexBimBinaryWriter = new BinaryWriter(wexBimFile))
		{
			model.SaveAsWexBim(wexBimBinaryWriter);
			wexBimBinaryWriter.Close();
		}
		wexBimFile.Close();
	}
		
	// Save IFC to the internal XBIM format, which includes geometry
	model.SaveAs(xbimDbFilename, StorageType.Xbim);
}

Screenshots

The XBIM Team have developed a couple of demonstrator apps to show how the toolkit can be used to develop your own applications. Both are open source under our team space on GitHub.

Xbim Xplorer WPF App The Windows Xbim Xplorer application is functional demonstrator application that shows off most of the functionality in the XBIM toolkit. The app supports visualising and inspecting multiple model files, as well as supporting plugins to export COBie, import/export BCF and more.

Xbim WebUI WebGL App The browser-based Xbim WeXplorer is a simple demonstrator of visualising models in a browser and an ability open sementic model data from a JSON structure.

Getting Started

You will need Visual Studio 2015 or newer to compile the Solution. Visual Studio 2017 is recommended. Prior versions of Visual Studio should work, but we'd recomments 2017 where possible The free VS 2017 Community Edition should work fine. All projects target .NET Framework 4.7, with some projects also targeting .netstandard2.0, which should permit limited trials of XBIM with .NET Core / Mono etc.

Using the library

To get started, the simplest approach is to add the Xbim.Essentials nuget package to your Visual Studio Project from Nuget.

Alternatively you can add the package using Nuget's Package Manager Console and issuing the following command:

PM> Install-Package Xbim.Essentials

Note that Xbim.Essentials is now a meta package. For more control it will be possible to add the dependent packages directly. (Which is necessary for .NET Core currently, as Essentials only targets net47)

Toolkit Overview

XBIM Libraries - high level dependencies

How to use it?

XbimEssentials is a software library to be used for the creation of complex applications, other repositories under the XbimTeam page include a number of example applications to demonstrate its capabilities.

If you wish to move your first steps these are the first resources to lookup:

  • The example list page can act as a short tutorial to familiarise with the library.

  • Small examples - a list of small console application demonstrating how to undertake simple IFC activities with Xbim that compiles and runs in visual studio.

  • XbimXplorer - is a fairly complex WPF sample application that can open and render 3D IFC models as well as displaying semantic data, its source code is available in the Xbim.WindowsUI repo.

Licence

The XBIM library is made available under the CDDL Open Source licence.

All licences should support the commercial usage of the XBIM system within a 'Larger Work', as long as you honour the licence agreements.

Third Party Licences

The core XBIM library makes use of the following 3rd party software packages, under their associated licences:

All 3rd party licences are permissive-style licences. We actively avoid Copyleft/GPL style licences to retain compatibility with our CDDL licence - meaning you can use the XBIM Toolkit in a closed-source commercial software package.

Support & Help

We have some guidance, examples and a FAQ on our docs site. We're always looking for help with areas like documentation - please see our Docs Repo if you think you can help with a PR.

For bugs, and improvements, please use the GitHub Issues of the relevant repository.

If you have a question, or need some help, you may find the Stackoverflow xbim tag a good place to start.

Acknowledgements

While we do not qualify anymore for open source licenses of JetBrains, we would like to acknowledge the good work and thank JetBrains for supporting the XbimToolkit project with free open source Resharper licenses in the past.

ReSharper Logo

Thanks also to Microsoft Azure DevOps for the use of Azure Pipelines to automate our builds.

Getting Involved

If you'd like to get involved and contribute to this project, please read the CONTRIBUTING page or contact the Project Coordinators @CBenghi and @martin1cerny.

xbimessentials's People

Contributors

alexmatv70 avatar andyward avatar artoymyp avatar bekraft avatar cbenghi avatar chuongmep avatar dmk-rib avatar dottormo avatar fomayette avatar gcoulby avatar haacked avatar i-sokolov avatar ibrahim5aad avatar jbrouwerdigibase avatar konstantinleontev avatar kozintsev avatar laurenceskoropinski avatar lloydpickering avatar martin1cerny avatar mezumroka avatar mlankamp avatar mseifert04 avatar prognostic-software avatar sense545 avatar stevelockley avatar urosjovanovic avatar xbimci avatar youshengcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xbimessentials's Issues

How to collect the geometry data from IFC file?

Hi,

This open source project is a great job! I spend a few days to study it but it is too huge for me. Actually what I need is to open an IFC file, import the structural element such as Beam, Wall, Slab, Column and its 3D geometry data. Can anyone give me some hints to do that? Thanks in advance.

Model merge

Is it possible to merge two or more models using XBim?

What is the status of Nuget package XBim.Essentials.4?

I notice that there is an XBim.Essentials.4 nuget package which is much newer than the standard XBim.Essentials package. However I don't see any formal release in the releases area of this project.
It seems that most of the XBim repos have a .4 nuget package as well.
Can anyone expand on the status of these packages? Are they superseding the standard (not .4) packages?

Also, is there anywhere that details some of the API changes? For example I see that there are still transactions but there is no IfcStore.Validate() whereas there was a XBimModel.Validate(). Is validation just not there anymore?

Thanks
Jero

IfcExtrudedAreaSolid holes information?

Hi,

I have an Ifc file exported from Revit. If open with Xbim Xplorer you will see 4 holes within a IfcSlab. When I try to retrieve the IfcSlab info programmatically, the IfcSlab is actually represented by IfcExtrudedAreaSolid, I check the IfcExtrudedAreaSolid.SweptArea and it is actually a IfcArbitraryClosedProfileDef and the outerCurve is a IfcPolyline type. My question is where do they store the holes information ? Thanks in advance.

SQLite database

Hello!

Why do you use the Esent rather than SQLite?
Do you have plans to use SQLite?

Exception on accessing ifcStore.DefaultOwningApplication if XbimEditorCredentials not provided on IfcStore.Create

In master branch (dll version 3.2):
The code in property IfcStore.DefaultOwningApplication assumes that _editorDetails is not null:
a.ApplicationName = _editorDetails.ApplicationFullName;

However, _editorDetails remains null using constructor
public static IfcStore Create(IfcSchemaVersion ifcVersion, XbimStoreType storageType)

Workaround: Provide editorDetails on Create()
public static IfcStore Create(XbimEditorCredentials editorDetails, IfcSchemaVersion ifcVersion, XbimStoreType storageType)

Can't delete *.xBim file if the ifc File is invlalid

Hello, I'm not sure if this is the right place.

When I open an invlaid ifc File an get an exception (there was an error in the string encoding, but I have the same thing with an invalid line, e.g. "#103= IFCBUILDING('1CP$KLp6fE0OAJmy4q$x53',#41,);
"), I can't delete the created *.xBim file as long my application is running.

xBimModel.CreateFrom(filePath, xBimFileName, LoadXbimProgress)

I use xBimModel in a using directive.
When I had a closer look, there where still a thread of or with the StepP21Parser running, so
I could not delete the file

Trying to get all Pset properties

Hello

I'm new in XBim and i want to make a testing application that should be able to open, modify and store all properties of IFC elements.
I followed this Guide https://www.youtube.com/watch?v=uZ3pAV7jp1o in order to add XBim package in to my application and now i'm trying to use it to do some simple tasks. At the moment I need to open all PSETS and I would like to know what is the "correct" method to do it.
Next i will need to modify these values and store them in the IFC file.

This is the code i'm using

        if (SelectedText == "IFCCOLUMN")
        {
            var TotalColumns = XBModel.Instances.OfType<Xbim.Ifc2x3.SharedBldgElements.IfcColumn>();
            Xbim.Ifc2x3.SharedBldgElements.IfcColumn col = TotalColumns.ElementAt(listBox1.SelectedIndex);
            textBox1.Text = "";
            var ifcObj = col as Xbim.Ifc2x3.Kernel.IfcObject;
            var ifcType = Xbim.IO.IfcMetaData.IfcType(ifcObj);

             Dictionary<IfcLabel, Dictionary<IfcIdentifier, IfcValue>> result = col.GetAllPropertySingleValues();

             for (int i = 0; i < result.Count; i++)
             {
                 var Meta = result.ElementAt(i).Value;
                 for (int j = 0; j < Meta.Count; j++)
                 {
                     var SubMeta = Meta.ElementAt(j);
                     textBox1.Text += "\t" + SubMeta.Key + ": " + SubMeta.ToString() + Environment.NewLine;
                 }
             }

            //Previous tests
            //for (int i = 0; i < ifcType.IfcProperties.Count; i++)
            //{
            //    Xbim.IO.IfcMetaProperty Meta = ifcType.IfcProperties.ElementAt(i).Value;
            //    textBox1.Text += "\t" + Meta.PropertyInfo.Name + ": " + Meta.PropertyInfo.GetValue(ifcObj) + Environment.NewLine;
            //}
            //for (int i = 0; i < ifcType.ExpressEnumerableProperties.Count(); i++)
            //{
            //        Xbim.IO.IfcMetaProperty Meta = ifcType.ExpressEnumerableProperties.ElementAt(i);
            //        textBox1.Text += "\t" + Meta.PropertyInfo.Name + ": " + Meta.PropertyInfo.GetValue(ifcObj) + Environment.NewLine;                   
            //}
        }

There was no argument keepLabels to method InsertCopy

I found a bug in file (developer version):

D:\GitHub\XbimEssentials\Xbim.IO\Esent\EsentModel.cs line 1032:

It was:

    public T InsertCopy<T>(T toCopy, XbimInstanceHandleMap mappings, PropertyTranformDelegate propTransform, bool includeInverses, bool keepLabels) where T : IPersistEntity
    {
        var txn = CurrentTransaction as XbimReadWriteTransaction;
        return Cache.InsertCopy(toCopy, mappings, txn, includeInverses, propTransform);
    }

Necessary:

    public T InsertCopy<T>(T toCopy, XbimInstanceHandleMap mappings, PropertyTranformDelegate propTransform, bool includeInverses, bool keepLabels) where T : IPersistEntity
    {
        var txn = CurrentTransaction as XbimReadWriteTransaction;
        return Cache.InsertCopy(toCopy, mappings, txn, includeInverses, propTransform, keepLabels);
    }

How to add a door to a wall?

I am experimenting with your toolkit, and it so far seems very useful. However, due to a lack of clear documentation, I'm struggling to understand how to compose hierarchies of objects.

For an example, let's assume I would like to create a wall, that has a door in it. Creating both the wall and the door themselves is fairly straightforward, after creating a model itself. But, how would one go about attaching the door to the wall?

How to capture propertySets for each geometry?

Hi @LloydPickering , @martin1cerny , @andyward , @benjymous, @CBenghi

I've been trying to get the Properties of each shape this way :

`

using (var geomStore = Model.GeometryStore)
{

    using (var geomReader = geomStore.BeginRead())
    {

        var shapeInstances = geomReader.ShapeInstance.Where(s => s.RepresentationType == XbimGeometryRepresentationType.OpeningsAndAdditionsIncluded && !excludedTypes.Contains(s.IfcTypeId));

        foreach (var shapeInstance in shapeInstances)
        {
            var ifcObjs = Model.Instances[shapeInstance.InstanceLabel] as IIfcObject;
            // then access the properties from ifcObjs
        }

    }

}

`

but shapeInstance.InstanceLabel is always equal to -1

Can anybody please help me with that?

Deleting / Removing stuff from the xbim model

Is there any plan to migrate the examples and documentation from version 2 to version 3?
My current issue is that I have to remove some elements out of an IFC model and I can't find a good way to do that.

Is there a forum or something that xBim users use. Google has not been my friend so far.

Can't compile Xbim.ModelGeometry.Converter project!

Hi,

It seems like all the native dlls TKBO.dll, TKBool.dll TKBRep.dll and etc didn't come along with the downloaded project. May I know where can I get all these dlls in order to compile Xbim.ModelGeometry.Converter successfully?

Thanks in Advance!

Culture specific typenames

Hello,

I would like to report a problem and suggest a fix in lfcMetaData.cs. The problem is related to the uppercase type names stored in TypeNameToIfcTypeLookup. The AddParent method adds culture dependent upper case type names in the dictionary TypeNameToIfcTypeLookup, which causes crashes as the type can not be found later when the program runs under Turkish language. In Turkish upper case 'i' is an uppercase 'I' with a dot over it. This may be an issue in similar languages as well.

The suggested fix is:

In lfcMetaData.cs line 195
string typeLookup = baseParent.Name.ToUpper()
should be changed to
string typeLookup = baseParent.Name.ToUpperInvariant()

This is working fine for the time being but I am not sure if such a fix won't be needed elsewhere.

Genericity

Hey,

I can't find a way other than hardcode or reflection to access PredefinedType (contained in for exemple IIfcSlab, IIfcBeam IIfcColumn and a lot more)
I'm trying to set a treeView by defined types and there is so many of them i was thinking that it would be accessible pretty generically.

Does a better way exists?

Delete PropertySet

Hi,

I am looking for a way to remove the property set itself after removing all its properties. I see AddPropertySet(), GetPropertySet but no RemoveProperyStet. Is there any way I can do this?

Best regards

How can I get the EntityLabel that i have use to get an IfcProduct?

Hello,
I have to get the EntityLabel of an product in particular to be used in the following code:

var product = model.Instances[entityLabel] as IfcProduct;
var propertyRelations = product.IsDefinedBy.OfType();
........
........

This I need to get the geometry of the product.

XbimSolid not in the right place

I am using the following code to get XbimSolid and build a solid with the faces coordinates, but when finished, the solids get far away from each other, like if some are on the right place and others on the origin. Can someone help me? Also, how can I find the IfcProduct of the XbimSolid? So I can try to get the transformation and also the attributes.
Thanks!

        List<Xbim.Ifc2x3.GeometryResource.IfcGeometricRepresentationItem> items = model.Instances.OfType<Xbim.Ifc2x3.GeometricModelResource.IfcExtrudedAreaSolid>().ToList<Xbim.Ifc2x3.GeometryResource.IfcGeometricRepresentationItem>();
        MessageBox.Show("Geometric - " + items.Count().ToString());


        for (int i = 0; i < items.Count(); i++)
        {


            if (items[i] is Xbim.Ifc2x3.GeometricModelResource.IfcExtrudedAreaSolid)
            {


                XbimGeometry.Interfaces.IXbimSolid solidotemp = _xbimGeometryCreator.Create(items[i]) as XbimGeometry.Interfaces.IXbimSolid;
        XbimGeometry.Interfaces.IXbimFaceSet faces = solidotemp.Faces;


    }
    }

capturar

Missing Property Data


var property = ifcModel.Instances.New<Xbim.Ifc2x3.PropertyResource.IfcPropertySingleValue>(psv =>
                    {
                        psv.Name = ifcProperty.Name;
                        psv.Description = ifcProperty.Description;                       
                        psv.NominalValue = new Xbim.Ifc2x3.MeasureResource.IfcText(ifcProperty.NominalValue);
                    });

                    var propertySet = ifcModel.Instances.New<Xbim.Ifc2x3.Kernel.IfcPropertySet>(ps =>
                    {
                        ps.HasProperties.Add(property);
                        ps.Name = ifcProperty.Name;
                        ps.Description = ifcProperty.Description;
                    });

                                       foreach (var instance in ifcModel.Instances.Where<Xbim.Ifc2x3.Kernel.IfcProduct>(
                        ins => ins.EntityLabel.Equals(productEntityLabel)))
                    {
                        instance.AddPropertySet(propertySet);
                    }

I am trying to insert property in the following way. Later it is saved to the IFC file like that:

#175043=IFCPROPERTYSINGLEVALUE('Construction',$,IFCTEXT('Yes'),$);
#175044=IFCPROPERTYSET($,#175045,'Construction',$,(#175043));
#175045=IFCOWNERHISTORY(#175048,#175049,$,.ADDED.,$,$,$,0);
#175046=IFCPERSON($,$,$,$,$,$,$,$);
#175047=IFCORGANIZATION($,$,$,$,$);
#175048=IFCPERSONANDORGANIZATION(#175046,#175047,$);
#175050=IFCORGANIZATION($,'Org',$,$,$);
#175049=IFCAPPLICATION(#175050,$,$,'Soft');
#175051=IFCRELDEFINESBYPROPERTIES($,#175045,$,$,(#37994),#175044);

The PSet and the property are now recognized by Solibry. Constructivity even says the file is invalid with the following errors:

#175044, IfcPropertySet, GlobalId, $, 
#175047, IfcOrganization, Name, $, 
#175049, IfcApplication, Version, $, 
#175049, IfcApplication, ApplicationFullName, $, 
#175051, IfcRelDefinesByProperties, GlobalId, $, 
#175053, IfcPropertySet, GlobalId, $, 
#175058, IfcApplication, Version, $, 
#175060, IfcRelDefinesByProperties, GlobalId, $, 

Stack overflow in IfcCsgPrimitive3D

Project: Xbim.Ifc2x3
File: IfcCsgPrimitive3D.cs
Problem:
Dim property - The get method references itself causing an immediate stack overflow.

Suggested fix: Specification defines that Dim should always be 3.

filter out all non-wall items and create a spatial view

Hi @CBenghi , @martin1cerny, @andyward

I have similar problem #15 , I want to filter out all non-wall items and create a Spatial view.

I have used the following code, but it is not populating the tree (Only project number appears on the tree). Could you please help?


private void OpenIfcFile(object s, DoWorkEventArgs args)
{
var worker = s as BackgroundWorker;
var ifcFilename = args.Argument as string;

        var model = new XbimModel();
        var modelCopy = new XbimModel();
        try
        {
            _temporaryXbimFileName = Path.GetTempFileName();
            SetOpenedModelFileName(ifcFilename);             

            if (worker != null)
            {
                model.CreateFrom(ifcFilename, _temporaryXbimFileName, worker.ReportProgress, true);
                string tempFileName = "";
                modelCopy = XbimModel.CreateModel(tempFileName);

                modelCopy.AutoAddOwnerHistory = false;
                using (var txn = modelCopy.BeginTransaction())
                {
                    var copied = new XbimInstanceHandleMap(model, modelCopy);
                    //modelCopy.InsertCopy(model.IfcProject, txn);
                    foreach (var item in model.Instances)
                    {
                        var ifctype = item.IfcType();
                        if (ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCPROJECT || 
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCBUILDING ||
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCBUILDINGSTOREY ||
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCSITE ||
                            ifctype.IfcTypeEnum == IfcEntityNameEnum.IFCWALLSTANDARDCASE )
                        {
                            modelCopy.InsertCopy(item, copied, txn, false);
                        }                        
                    }

                    txn.Commit();
                }

                var context = new Xbim3DModelContext(modelCopy);//upgrade to new geometry represenation, uses the default 3D model
                context.CreateContext(geomStorageType: XbimGeometryType.PolyhedronBinary,  progDelegate: worker.ReportProgress,  adjustWCS: false);

                if (worker.CancellationPending) //if a cancellation has been requested then don't open the resulting file
                {
                    try
                    {
                        model.Close();
                        if (File.Exists(_temporaryXbimFileName))
                            File.Delete(_temporaryXbimFileName); //tidy up;
                        _temporaryXbimFileName = null;
                        SetOpenedModelFileName(null);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message, ex);
                    }
                    return;
                }
            }
            args.Result = modelCopy;

        }
        catch (Exception ex)
        {
            var sb = new StringBuilder();
            sb.AppendLine("Error reading " + ifcFilename);
            var indent = "\t";
            while (ex != null)
            {
                sb.AppendLine(indent + ex.Message);
                ex = ex.InnerException;
                indent += "\t";
            }

            args.Result = new Exception(sb.ToString());
        }
    }


Using Mono

I just want to know if it is possible to use mono with XbimEssentials or not.

With IFC it works allright, but very limited functionality, and not supported. If I use XbimEssentials with this example http://www.overarching.it/wordpress/2014/03/05/xbim-data-investigation-and-export-overarching-2/

Then I first get an error related to Log4Net not being able to find configuration file. When I fix that by adding it in app.config then I get a TypeInitialzationException in Xbim.IO.IfcPersistedInheritanceCache. This happens in XbimModel model = new XbimModel()

Do I have to use Windows server or is there any alternatives?

XbimModel.Delete() is throwing Method Not Implemented Exception

I am attempting to create a method to delete elements in a model; however, I get the follwoing exception from the code below.

Exception:
"The method or operation is not implemented."

Code:

    public static string Delete(XbimModel IfcModel, IfcElement IfcElement)
    {
        try
        {
            List<IPersistIfcEntity> m_IPersistObjects = IfcModel.Instances.OfType("IfcElement", true).ToList(); ;

            foreach (IPersistIfcEntity m_PersistObj in m_IPersistObjects)
            {
                IfcElement m_Element = m_PersistObj as IfcElement;

                if(m_Element.Name.ToString().ToLower() == IfcElement.Name.ToString().ToLower())
                {
                    // Delete existing 
                    using (XbimReadWriteTransaction txn = IfcModel.BeginTransaction("Delete IfcElement"))
                    {
                        IfcModel.Delete(m_PersistObj);
                    }
                    return c._Success;
                }
            }    
        }
        catch { }
        return null;
    }

Problem in getting quantities

Hi guys I'm a begginner user of the xBim project, and I'm trying to create a BIM explorer interface, the problem that I'm currently facing is that I can get all IFC products and quantities, butI don't know how to related them. For example, for a wall I want to get what are its quantities.

I was reading and testing the code provided in the documentation section, but it seems to be out of date, and some function do not exist anymore. So how can I get the quantities related with some IFC product?

Sorry for posting here.

Thanks!

Add Element to IfcBuildingStorey

Dear xBim Team,

I created a storey (IfcBuildingStorey) and a few columns (IfcColumn). I would like to add column into IfcBuildingStorey.

public static void WriteColumn(Column w, XbimModel model, IfcBuilding building, double min, double max, IfcBuildingStorey storey)
{
IfcColumn wall = CreateColumn(model, w, min, max);
if (wall != null)
{
AddPropertiesToColumn(model, wall);
}
using (XbimReadWriteTransaction txn = model.BeginTransaction("Add Storey"))
{
storey.AddElement(wall);
building.AddElement(wall);
txn.Commit();
}
}

I write the code as above. But storey.AddElement() throw out an exception saying "Unable to cast object of type 'Xbim.Ifc2x3.SharedBldgElements.IfcColumn' to type 'Xbim.Ifc2x3.ProductExtension.IfcSpatialStructureElement'." .

May I know how to correctly assign a relation between Building Storey and an elements?
Thanks!

ManagedEsent 1.9.3.3 problem

I use xBim develop (Xbim.Essentials.4.0.0-V198) and found problem if update ManagedEsent from 1.9.2.0 to 1.9.3.3 (in my project).
Please test it.

The problem occurs if to call the xBim library from another library( which uses a standard mechanism for application extensions in .NET - Managed Extensibility Framework (MEF)).
In my case ...

IfcProxy (2x3): Tag and ProxyType attribute are not written in an ifc file

Dear xBIM team,
I am facing the following problem (bug??):

var ifcProxy = model.Instances.New();
ifcProxy.Name = "TestCuboid";
ifcProxy.Tag = new IfcLabel("TestTag");
ifcProxy.ProxyType= IfcObjectType.NotDefined;
...

is written as
#20=IFCPROXY('0UvNqIQW9AvAeKkg$mFvZJ',#11,'TestCuboid',$,$,#82,#69);

but should be written as
#20=IFCPROXY('0UvNqIQW9AvAeKkg$mFvZJ',#11,'TestCuboid',$,$,#82,#69,.NOTDEFINED.,'TestTag');

Thanks and regards,
Dominic

Not rendering correct wexBIM after conversion

Hi, guys I have some great issues with the latest version of the myget packages. The rendering of the wexBIM file after the conversion is getting worse. I am attaching a screenshot. In my last issue I posted the file that I am playing with. In one of the previous versions it was working great.

IfcInputStream not found, Reading + Editing existing IFC

Hello,

Im trying out the toolkit. I have a presumably an older example SimpleOpenAndSaveIfcFile where an existing IFC file is read that uses the IfcInputStream:

IfcInputStream input = new IfcInputStream(new FileStream(ifcFileName, FileMode.Open, FileAccess.Read));

I also have a the HelloWallExample but apparently the Xbim.IO referenced to this project does not contain anymore the IfcInputStream.

Could you please point me out where to look for the IfcInputStream? Has it been renamed or deprecated? Or is there a an example for reading + editing an existing IFC file in another way? I have tried using the XbimModel.CreateFrom() function but it gives me an error.

Thanks in advance for the feedback.

PS: Sorry for using the tracker but the discussion forum link is dead.

Exception thrown when Validating an IFC File

I have found a bug.
When I try to validate some IFC files, a have an exception saying that :
_firstOperande of Xbim.Ifc2x3.GeometricModelResource.IfcBooleanResult is null, at lines 118 and 126.

I believe it's not supposed to be, and better write down the problem in the validation output.

VRML

Hello!
Can Xbim Essentials save the IFC file as VRML (Virtual Reality Modeling Language) ?
Or maybe there is another way to save IFC file as VRML?

Exception, when Reading ifc Files with IfcBuildingElement

I know this class is abstract. Nevertheless there are Ifc File Reader (Solibri, DDS-CAD Viewer), that accept this Type.
I am working with your Framework, and it threw exceptions.
The IFC File was generated from 'Nemetschek Vectorworks, Inc.' with 'Vectorworks Architect 2015 SP3 R1 (Build 257190) (64-Bit) by Nemetschek Vectorworks, Inc.'

Wouldn't it be nice to accept such files even thoug they are 'invalid'

Failed to add entity to the database

During the research the xBIM Toolkit I found the problem.
Unfortunately, InsertCopy method throws an exception:
Message = "Failed to add entity to the database"
InnerException = {"Illegal duplicate key"}

The test was taken from the file:
https://github.com/xBimTeam/XbimEssentials/blob/master/Xbim.Essentials.Tests/ModelFilterTest.cs

As well as, I write test:

   [TestMethod]
    public void CopyFileToFileTest()
    {
        using (var source = new XbimModel())
        {

            PropertyTranformDelegate propTransform = delegate (IfcMetaProperty prop, object toCopy)
            {
                var value = prop.PropertyInfo.GetValue(toCopy, null);
                return value;
            };
            string ifcFilename_1 = @"c:\\Temp\\House_1.ifc",
                ifcFilename_2 = @"c:\\Temp\\House_2.ifc";               
            source.CreateFrom(ifcFilename_1, Path.GetTempFileName(), null, true);
            source.CacheStop();
            using (var target = new XbimModel())
            {
                target.CreateFrom(ifcFilename_2, Path.GetTempFileName(), null, true);
                target.CacheStop();
                target.AutoAddOwnerHistory = false;
                using (var txn = target.BeginTransaction())
                {
                    var copied = new XbimInstanceHandleMap(source, target);
                    foreach (var item in source.Instances)
                    {
                        target.InsertCopy(item, copied, txn, propTransform);
                    }
                    txn.Commit();
                }
                target.SaveAs(ifcFilename_2);
            }
            source.Close();
            //the two files should be the same
        }
    }

`

In file XbimEntityCursor.cs, method AddEntity throws an exception line 382.
internal void AddEntity(int currentLabel, short typeId, IEnumerable<int> indexKeys, byte[] data, bool? indexed, XbimLazyDBTransaction? trans = null)

Not rendering correct wexBIM after conversion

Hi guys,
After I updated the myget packages to the latest the browser stopped rendering correct the model after it's been converted to wexBIM. I attach screenshots of the problem.
building1
rac_basic_sample

IFC4 support

Hi, I see there is a dev branch for IFC4 support.

Do you have an estimate on when it will be ready and promoted to master branch?

Thanks!

Latest XBimGeometry nuget incompatible with Essentials 3.1.1 on Myget master

Steve, it looks like this commit 10aa6f1 made a breaking change to IXbimGeometryCreator - a new Create() overload which has not been implemented in XbimTeam/XbimGeometry's Interop dll yet.

Anyone who gets the latest Essentials and Geometry from myget Master will have issues creating geometry since 3.0.24 of XbimGeometry engine is not compatible.

Is that an oversight, or should we stub in an implementation for now?

Workaround is to get the prior version of XbimEssentials (3.0.23)

Andy

About XbimMemoryModel

I want to ask a question
Form codeplex, there is a class name XbimMemoryModel,but i can not find it in the source code package of Xbim.XbimExtensions

// ---- code from codeplex --------------
Xbim.XbimExtensions.IModel model = null;

//get a stream to access the ifc data
Xbim.IO.IfcInputStream input = new Xbim.IO.IfcInputStream(new FileStream(ifcFileName, FileMode.Open, FileAccess.Read));

//create an empty model
model = new Xbim.XbimExtensions.XbimMemoryModel();

//load entities into the model
errors = input.Load(model);
// ---- end --------------

and this is the link
http://xbim.codeplex.com/wikipage?title=Walkthrough%20Sample%201%3A%20Export%20data%20from%20an%20IFC%20File%20to%20an%20Excel%20Spreadsheet

is this XbimMemoryModel built model fast than XbimModel?
where i can get this XbimMemoryModel

[Question]Domain entities filling

Hello,
i'm searching the greatest way to fill a list of all the entities from mep domain(electrical, plombing..)
But it seem to be have no link between an entity and its "MepDomain" in IFC4 ?

have you please got an idea ?

thanks for help

Xbim.IO.IfcOutputStream & IfcConnectionPointGeometry

Hi Everyone,

I have a problem with Xbim.IO.IfcOutputStream
(sorry if this is not the proper place to ask)

Here is what happens to me

I call, on an IfcOutputStream object, the Store method,
passing an Xbim.XbimExtensions.XbimMemoryModel with all IfcConnectionPointGeometry with PointOnRelatingElement = a specific IfcVertexPoint

In my ifc file, generated by storage, then I found all those IfcVertexPoint and all those IfcConnectionPointGeometry, but these latter ones are with no arguments, like you see here:
172=IFCCONNECTIONPOINTGEOMETRY();
173=IFCCONNECTIONPOINTGEOMETRY();
174=IFCCONNECTIONPOINTGEOMETRY();
175=IFCCONNECTIONPOINTGEOMETRY();
176=IFCCONNECTIONPOINTGEOMETRY();
177=IFCCONNECTIONPOINTGEOMETRY();
178=IFCCONNECTIONPOINTGEOMETRY();
179=IFCCONNECTIONPOINTGEOMETRY();

model.InsertCopy: missing step instance names inside file by using Esent

Hello,

I am copying from multiple ifc files the IfcShapeRepresentations into new created model, using
destinationModel.InsertCopy(toCopy, mapping, Filter, false, false);. This is used for a tool which shall convert ifc files containing generic BuildingElementProxy to correct ifc product type, with attributes defined inside a SQL database.

This works perfect as long as destinationModel is created by XbimStoreType.InMemoryModel. If EsentDatabase is used, no referenced step instance names are getting added inside file to ifc objects added by code:

destination file output:

#228=IFCCURTAINWALLTYPE('2jOin3JCn7r8OHsq71vF9B',#4,'Curtain Wall  test',$,'IfcCurtainWall',$,$,$,$,.USERDEFINED.);
#229=IFCLOCALPLACEMENT($,#193);
#230=IFCPRODUCTDEFINITIONSHAPE($,$,());
#231=IFCSHAPEREPRESENTATION($,'Body','SurfaceModel',());

Issue:

#228: should contain #229 and #230
#230: () should contain (#231)
#231 () should contain.. 
#231 is the object returned by InsertCopy. The references in lower nested objects are correct

Using InMemoryModel works! In debugger the objects are looking correct, with referenced objects.

Related to Nuget package 4.0.2 from 16 October 2016

Any idea?

(Note; I've edited the comment because some parts where mistakenly interpreted as references to issues from github. Claudio)

Validate IFC 2.3 model

In previous Xbim version, I was able to validate my model with:
model.Validate(t.Modified(), writer);
Now with IfcStore, Validate method does not exists anymore.
What is the new way to validate my data?
Thank you for your help

Where methods moved from version 3?

Hello!

Where are the methods:
buildingStorey.AddElement ?
project.AddSite(site) ?
project.AddBuilding(building) ?

etc.

Maybe there are common methods for IFC2x3 ΠΈ IFC4 ?
Do you have an example?

Thank you for attention.

How to create XBimModel from .xBim binary file?

Hi,

I know how to create an instant of XBimModel from .ifc file.
But I don't know how to create an instant of XBimModel from .xBim binary file?

Something like this:
var model = new Xbim.IO.XbimModel();
model.CreateFrom(xBimFile,....);

The reason is my IFC file is very big then it takes ages to create instant of XBimModel in the first time then I don't want to parse IFC file everytime. Therefore I think I should parse the .xBim instead in the second time as it should be faster than IFC text format.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.