Autodesk Revit MEP 2010 .NET API C# 房间到门的关系

发布于 2024-08-07 06:57:24 字数 1192 浏览 1 评论 0原文

在 C# 中使用 VS 2008 和 Autodesk Revit MEP 2010 我试图查明门是否连接到房间:

ElementSetIterator elementsetiteratorBIMDoors = 
  bimdoors.getBIMDoors().ForwardIterator();

while (elementsetiteratorBIMDoors.MoveNext())
{
    Autodesk.Revit.Element elementDoor = 
      elementsetiteratorBIMDoors.Current as Autodesk.Revit.Element;

    if ((null != elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID)) && 
        (null != elementDoor.get_Parameter(BuiltInParameter.TO_ROOM_ID)))
    {
        string sDoorFromRoomID = 
              elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID).ToString();
        string sDoorToRoomID = 
              elementDoor.get_Parameter(BuiltInParameter.TO_ROOM_ID).ToString();

        graph.addLink(new Link(sDoorFromRoomID, sDoorToRoomID));
    }
}

此方法不起作用,因为 elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID) 的返回值始终为null

我在 Building Coder 博客上读到

内置参数不是 API 的官方支持部分。在 未来我们预计它将被正确公开的数据所取代 属性。

这种说法属实吗?谁能指出一种有效的方法来获取门和房间之间的关系?

Working with VS 2008 and Autodesk Revit MEP 2010 in C# I am trying to find out if a door is connecting to rooms:

ElementSetIterator elementsetiteratorBIMDoors = 
  bimdoors.getBIMDoors().ForwardIterator();

while (elementsetiteratorBIMDoors.MoveNext())
{
    Autodesk.Revit.Element elementDoor = 
      elementsetiteratorBIMDoors.Current as Autodesk.Revit.Element;

    if ((null != elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID)) && 
        (null != elementDoor.get_Parameter(BuiltInParameter.TO_ROOM_ID)))
    {
        string sDoorFromRoomID = 
              elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID).ToString();
        string sDoorToRoomID = 
              elementDoor.get_Parameter(BuiltInParameter.TO_ROOM_ID).ToString();

        graph.addLink(new Link(sDoorFromRoomID, sDoorToRoomID));
    }
}

This approach does not work because the return value of elementDoor.get_Parameter(BuiltInParameter.FROM_ROOM_ID) is always null.

I have read on the Building Coder blog that

Built-in parameters are not an officially supported portion of API. In
future we expect it will be replaced by data being properly exposed as
a property.

Is that statement true? Can anyone point me to an efficient way to get the relation between doors and rooms?

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

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

发布评论

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

评论(1

一直在等你来 2024-08-14 06:57:24

门是家庭实例,因此

Autodesk.Revit.Elements.FamilyInstance elementDoor = elementsetiteratorBIMDoors.Current as Autodesk.Revit.Elements.FamilyInstance;

Room fromRoom = elementDoor.FromRoom;
Room toRoom = elementDoor.ToRoom;

应该适用于此。

Doors are family instances, so

Autodesk.Revit.Elements.FamilyInstance elementDoor = elementsetiteratorBIMDoors.Current as Autodesk.Revit.Elements.FamilyInstance;

Room fromRoom = elementDoor.FromRoom;
Room toRoom = elementDoor.ToRoom;

should work for this.

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