我正在处理一个应用程序,它需要知道哪个房间的边框是哪个房间的。在这种情况下,知道一个房间的边框是墙还是隔间器是相关的。
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
}
}但是,在2017年的REVIT2017中,这段代码抛出了未找到的方法:'Autodesk.Revit.DB.Element Autodesk.Revit.DB.Element表示此方法已被删除的异常。
var geometry = (Solid)room.get_Geometry(new Options()).First();
var faces = geometry.Faces;虽然这确实允许我判断任何东西,无论地板是否站在一个角度,它并不能告诉我,哪些边缘来自墙壁,哪些来自房间的缝纫机。
理想情况下,我可以把我们的脸和检查,看看是否有任何边缘的脸是一个房间分隔器。如果这有帮助的话,我已经有一张所有墙壁的清单了。
那么,在2017年,人们是如何做到这一点的呢?最好不破坏2015年的可压缩性。
发布于 2016-07-07 12:49:03
这是在平台API更改和添加文件(见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)
{
}
}发布于 2016-07-07 16:44:30
上面提到的Revit更改和添加了文档,也可以在网上获得:
http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html
只需搜索BoundarySegment。您缺少的get_Element方法实际上是Element属性的包装器,该属性在Revit2017中被删除。
一个示例演示如何使用.NET 反射库支持不同版本的Revit中的不同功能,该示例由Building提供
http://thebuildingcoder.typepad.com/blog/2012/07/multi-version-add-in.html
https://stackoverflow.com/questions/38245018
复制相似问题