revitapi ironpython ToRoom返回“索引器#对象" [英] revitapi ironpython ToRoom returns "indexer # object"

查看:82
本文介绍了revitapi ironpython ToRoom返回“索引器#对象"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Revit API中,我试图访问门的ToRoom/FromRoom属性. ironpython中的简化代码段:

in revit api i am trying to access the ToRoom / FromRoom properties for doors. the simplified code snippet in ironpython:

fc = FilteredElementCollector(doc)
doors = fc.OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()

for door in doors:
    froom = door.FromRoom

我的结果是索引器#对象位于0x0000000000035" 我如何从这里访问房间对象?

my result is an "indexer # object at 0x0000000000035" how can i access the room object from here?

推荐答案

这是IronPython/时髦的Revit API问题.基本上,FromRoom的定义方式可以是属性或索引属性.请参阅 FromRoom的API文档.

This is an IronPython / funky Revit API issue. Basically, the way FromRoom is defined, it can be either a property or an indexed property. See the API documentation for FromRoom.

您获得的索引器"是FromRoom的第二个版本-它以Phase作为其参数.因此,您基本上可以做到这一点:

The "indexer" you get is the second version of FromRoom - it takes a Phase as its argument. So you can basically do this:

phase = list(doc.Phases)[0]
room = door.FromRoom[phase]

由于FromRoom的文档说它返回

在项目的最后阶段为门或窗户设置的从房间".

The "From Room" set for the door or window in the last phase of the project.

您实际上可能想这样做:

You probably actually want to do this:

phase = list(doc.Phases)[-1]  # retrieve the last phase of the project
room = door.FromRoom[phase]

我无法弄清楚如何掌握其他版本的FromRoom ...

I was not able to figure out how to get hold of the other version of FromRoom...

这篇关于revitapi ironpython ToRoom返回“索引器#对象"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆