使用C#创建IFC文件

发布于 2025-02-08 23:54:39 字数 302 浏览 2 评论 0原文

有谁知道使用C#创建IFC文件或至少IFC对象的广泛方法? 我正在尝试根据由C#编码的计算产生的类实例创建对象。在这种情况下,使用像Revit这样的创作软件的API不是一个选择。

我只知道这个资源,但它似乎不包含创建对象的方法,只有几何形状: https://docs.xbim.net/

将对任何提示或方向指针表示感谢! 欢迎在其他编程语言中进行同样的事情的信息。

非常感谢!

Does anyone know if there is already a widespread way of creating IFC files, or at least IFC objects, using C#?
I am trying to create objects based on class instances that result from a calculation which is coded in C#. The use of APIs of authoring software like Revit is not an option in this case.

I know only this resource, but it doesn't seem to contain a way of creating objects, only geometries:
https://docs.xbim.net/

Would be grateful for any hints or direction pointers!
Infos about doing the same in other programming languages are also welcome.

Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哀由 2025-02-15 23:54:39

有一个相当全面的示例创建一个ifcwall元素/对象:

https:// docs.xbim.net/examples/proper-wall-in-3d.html

和github中的完整示例 https://github.com/xbimteam/xbimsamplees/blob/master/master/hellowall/hellowall/hellowall/helledall/hellowalllexpample.cs

,它证明了创建对象的创建对象,包括(包括)几何学)。 XBIM必需品可让您读取并写入整个IFC模式,其中包括几何形状。但是,如果您只想创建一个元素,那就很简单了:

IModel model = BuildModel(); // There's a bit of bootstrapping in the example to create the base model and define an IFC Project and Building

using (var txn = model.BeginTransaction("Create Wall"))
{
    var wall = model.Instances.New<IfcWallStandardCase>();
    wall.Name = "A Standard rectangular wall";
    // ...*snipped* everything else that create representation, placement, materials etc
    txn.Commit();   
    return wall;
}

这只是将墙元素添加到结构中的问题。该示例中使用的助手是将墙添加到建筑物中的助手:

using (var txn = model.BeginTransaction("Add Wall"))
{
    building.AddElement(wall);
    txn.Commit();
}

最后,您将模型保存到IFC步骤文件中。

model.SaveAs("HelloWallIfc4.ifc", IfcStorageType.Ifc);

There's a fairly comprehensive example creating an IfcWall element/object:

https://docs.xbim.net/examples/proper-wall-in-3d.html

and the full example in Github at https://github.com/xBimTeam/XbimSamples/blob/master/HelloWall/HelloWallExample.cs

That demonstrates the creating the object and a lot more besides (including geometry). xbim Essentials lets you read and write the whole IFC schema, which can include the geometry. But if you just want to create an element it's pretty simple:

IModel model = BuildModel(); // There's a bit of bootstrapping in the example to create the base model and define an IFC Project and Building

using (var txn = model.BeginTransaction("Create Wall"))
{
    var wall = model.Instances.New<IfcWallStandardCase>();
    wall.Name = "A Standard rectangular wall";
    // ...*snipped* everything else that create representation, placement, materials etc
    txn.Commit();   
    return wall;
}

Then it's just a matter of adding the wall element to the structure. There's a helper for this used in the example to add the wall to the building:

using (var txn = model.BeginTransaction("Add Wall"))
{
    building.AddElement(wall);
    txn.Commit();
}

Lastly you'd save the model to an IFC Step file.

model.SaveAs("HelloWallIfc4.ifc", IfcStorageType.Ifc);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文