我如何在 Revit 2017 中获得房间分隔符
How do I obtain room seperators in revit 2017
我正在开发一个应用程序,它需要了解哪个房间的边界。在这种情况下,了解房间边界是墙还是房间分隔符很重要。
public FindsRoomSeperators(){
SpatialElementBoundaryOptions options = new SpatialElementBoundaryOptions();
options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;
foreach (IList<Autodesk.Revit.DB.BoundarySegment> boundSegList in room.GetBoundarySegments(options))
{
foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundSegList)
if ((BuiltInCategory)el.Category.Id.IntegerValue == BuiltInCategory.OST_RoomSeparationLines)
//proccess el
}
}
然而,作为 revit 2017 的代码,此代码现在抛出找不到方法:'Autodesk.Revit.DB.Element Autodesk.Revit.DB.BoundarySegment.get_Element()'。提示此方法已被删除的异常。
var geometry = (Solid)room.get_Geometry(new Options()).First();
var faces = geometry.Faces;
虽然这确实允许我判断诸如地板是否以一定角度站立之类的东西,但它并没有告诉我哪些边缘来自墙壁,哪些来自房间分隔符。
理想情况下,我将能够拍摄我们拥有的面孔并检查是否有任何面孔边缘是房间分隔符。如果有帮助的话,我已经有了所有墙的清单。
那么如何在 Revit 2017 中做到这一点呢?最好不要破坏与 2015 的兼容性。
在 Revit 平台 API 更改和添加 文件 (see SDK) 中预期并记录了该方法,此方法在 2016 年被标记为已弃用,并于于 2017 年移除。
您应该使用 ElementId 或 LinkElementId(参见文档)。
foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundSegList)
{
Element el = doc.GetElement(boundSeg.ElementId); // or doc.GetElement(boundSeg.LinkElementId);
if ((BuiltInCategory)el.Category.Id.IntegerValue == BuiltInCategory.OST_RoomSeparationLines)
{
}
}
Augusto 上面提到的 Revit 平台 API 更改和补充 文档也可在线获得:
http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html
只需搜索 BoundarySegment。您缺少的 get_Element
方法实际上是 Element
属性 的包装器,已在 Revit 2017 中删除。
The Building Coder 在
提供了一个演示如何使用 .NET Reflection 库来支持不同版本 Revit 中的不同功能的示例
http://thebuildingcoder.typepad.com/blog/2012/07/multi-version-add-in.html
我正在开发一个应用程序,它需要了解哪个房间的边界。在这种情况下,了解房间边界是墙还是房间分隔符很重要。
public FindsRoomSeperators(){
SpatialElementBoundaryOptions options = new SpatialElementBoundaryOptions();
options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;
foreach (IList<Autodesk.Revit.DB.BoundarySegment> boundSegList in room.GetBoundarySegments(options))
{
foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundSegList)
if ((BuiltInCategory)el.Category.Id.IntegerValue == BuiltInCategory.OST_RoomSeparationLines)
//proccess el
}
}
然而,作为 revit 2017 的代码,此代码现在抛出找不到方法:'Autodesk.Revit.DB.Element Autodesk.Revit.DB.BoundarySegment.get_Element()'。提示此方法已被删除的异常。
var geometry = (Solid)room.get_Geometry(new Options()).First();
var faces = geometry.Faces;
虽然这确实允许我判断诸如地板是否以一定角度站立之类的东西,但它并没有告诉我哪些边缘来自墙壁,哪些来自房间分隔符。
理想情况下,我将能够拍摄我们拥有的面孔并检查是否有任何面孔边缘是房间分隔符。如果有帮助的话,我已经有了所有墙的清单。
那么如何在 Revit 2017 中做到这一点呢?最好不要破坏与 2015 的兼容性。
在 Revit 平台 API 更改和添加 文件 (see SDK) 中预期并记录了该方法,此方法在 2016 年被标记为已弃用,并于于 2017 年移除。
您应该使用 ElementId 或 LinkElementId(参见文档)。
foreach (Autodesk.Revit.DB.BoundarySegment boundSeg in boundSegList)
{
Element el = doc.GetElement(boundSeg.ElementId); // or doc.GetElement(boundSeg.LinkElementId);
if ((BuiltInCategory)el.Category.Id.IntegerValue == BuiltInCategory.OST_RoomSeparationLines)
{
}
}
Augusto 上面提到的 Revit 平台 API 更改和补充 文档也可在线获得:
http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html
只需搜索 BoundarySegment。您缺少的 get_Element
方法实际上是 Element
属性 的包装器,已在 Revit 2017 中删除。
The Building Coder 在
提供了一个演示如何使用 .NET Reflection 库来支持不同版本 Revit 中的不同功能的示例http://thebuildingcoder.typepad.com/blog/2012/07/multi-version-add-in.html