2016-07-07 72 views
1

我正在開發一個應用程序,需要了解哪個房間邊界是其他的。在這種情況下,知道房間邊界是牆壁還是房間分隔符是相關的。如何在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 
       } 
    } 

然而,隨着2017年的Revit這個代碼現在拋出找不到方法: 'Autodesk.Revit.DB.Element Autodesk.Revit.DB.BoundarySegment.get_Element()'。意外提示此方法已被刪除。

 var geometry = (Solid)room.get_Geometry(new Options()).First(); 
     var faces = geometry.Faces; 

雖然這並不讓我來判斷的東西像什麼或不是地板是站在一個角度它並沒有告訴我哪個邊緣來自牆壁和從房間sepeartors。

理想情況下,我將能夠拍攝我們擁有的臉並檢查臉部的任何邊緣是否爲房間分隔符。如果有幫助,我已經有了所有牆的列表。

那麼如何做到這一點在revit 2017?最好在不破壞兼容性與2015年

+0

的GetBoundarySegments()不是從API取消了對2017年提供的,但它仍然存在(甚至沒有標記爲「過時」)。你不錯過參考嗎? –

+0

該代碼在2017年調用時會在foreach循環中引發異常,但在2016年可以正常工作。上述方法拋出異常:未找到方法:'Autodesk.Revit.DB.Element Autodesk.Revit.DB.BoundarySegment.get_Element()'。 – Thijser

回答

2

這是預期和記錄上,該方法被標記爲已過時2016年和2017年上

而是去除Revit平臺API更改和添加文件(see SDK)你應使用ElementIdLinkElementId(請參閱文檔)。

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) 
    { 

    } 
} 
+0

難道在revit 2015中不存在boundSeg.ElementId?它給了我一個錯誤:Boundry段不包含'ElementID'的定義。 – Thijser

+0

是的,BoundarySegment.ElementId屬性是在2016年推出的(根據文檔) –

+0

你碰巧知道一種讓我同時使用的方法嗎?我需要在2015年和2017年都有競爭力。 – Thijser

2

Revit平臺API更改和添加文檔是奧古斯都指向上方也可在網上:

http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html

簡單搜索BoundarySegment。該get_Element方法你缺少實際是對這個Element屬性,它是在Revit取出一個包裝2017

展示瞭如何使用.NET 反射庫,以支持不同版本的Revit的不同功能的示例是由建築編碼器在

http://thebuildingcoder.typepad.com/blog/2012/07/multi-version-add-in.html

相關問題