源文件/模型轉換完成以後,能夠獲取模型的具體數據。本篇介紹根據文件ID查詢知足條件的構件ID列表。html
請求地址:GET https://api.bimface.com/data/v2/files/{fileId}/elementIds
api
說明:根據六個維度(專業,系統類型,樓層,構件類型,族,族類型)獲取對應的構件ID列表,任何維度都是可選的。restful
構件ID分頁查詢相關請參考這裏 測試
同時,也支持根據空間關係從房間計算出房間內的構件ID列表this
構件與房間空間關係計算相關請參考這裏 url
參數:
spa
請求 path(示例):https://api.bimface.com/data/v2/files/1211223382064960/elementIdsrest
請求 header(示例):"Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b"code
HTTP響應示例(200):orm
{ "code": "success", "message": null, "data": [ "1107237", "1109326", "1107234", "1109327", "1107235", "1107239", "1109329", "1107236", "1109325", "1107238", "1109328" ] }
C#實現方法:
1 /// <summary> 2 /// 查詢知足條件的構件ID列表 3 /// </summary> 4 /// <param name="accessToken">令牌</param> 5 /// <param name="fileId">文件ID</param> 6 /// <param name="request">請求參數對象</param> 7 /// <returns></returns> 8 public virtual FileElementsGetResponse GetFileElements(string accessToken, string fileId, FileElementsGetRequest request = null) 9 { 10 // GET https://api.bimface.com/data/v2/files/{fileId}/elementIds 11 string url = string.Format(BimfaceConstants.API_HOST + "/data/v2/files/{0}/elementIds", fileId); 12 13 BimFaceHttpHeaders headers = new BimFaceHttpHeaders(); 14 headers.AddOAuth2Header(accessToken); 15 16 string data = string.Empty; 17 if (request != null) 18 { 19 data = request.SerializeToJson(); 20 } 21 22 try 23 { 24 FileElementsGetResponse response; 25 26 HttpManager httpManager = new HttpManager(headers); 27 HttpResult httpResult = httpManager.Get(url, data); 28 if (httpResult.Status == HttpResult.STATUS_SUCCESS) 29 { 30 response = httpResult.Text.DeserializeJsonToObject<FileElementsGetResponse>(); 31 } 32 else 33 { 34 response = new FileElementsGetResponse 35 { 36 Message = httpResult.RefText 37 }; 38 } 39 40 return response; 41 } 42 catch (Exception ex) 43 { 44 throw new Exception("[查詢知足條件的構件ID列表]發生異常!", ex); 45 } 46 }
其中調用到的 httpManager.Get() 方法,請參考《C# HTTP系列》
封裝的其餘請求參數類 FileElementsGetRequest
1 /// <summary> 2 /// 查詢知足條件的構件ID列表請求參數類 3 /// </summary> 4 [Serializable] 5 public class FileElementsGetRequest 6 { 7 public FileElementsGetRequest() 8 { 9 CategoryId = null; 10 Family = null; 11 FamilyType = null; 12 Floor = null; 13 PaginationContextId = null; 14 PaginationNo = null; 15 PaginationSize = null; 16 RoomId = null; 17 RoomToleranceXY = null; 18 RoomToleranceZ = null; 19 Specialty = null; 20 SystemType = null; 21 } 22 23 ///// <summary> 24 ///// 【必填】表明該單模型的文件ID 25 ///// </summary> 26 //[JsonProperty("fileId")] 27 //public long FileId { get; set; } 28 29 /// <summary> 30 /// 【非必填】篩選條件構件類型id 31 /// </summary> 32 [JsonProperty("categoryId",NullValueHandling = NullValueHandling.Ignore)] 33 public string CategoryId { get; set; } 34 35 /// <summary> 36 /// 【非必填】篩選條件族 37 /// </summary> 38 [JsonProperty("family", NullValueHandling = NullValueHandling.Ignore)] 39 public string Family { get; set; } 40 41 /// <summary> 42 /// 【非必填】篩選條件族類型 43 /// </summary> 44 [JsonProperty("familyType", NullValueHandling = NullValueHandling.Ignore)] 45 public string FamilyType { get; set; } 46 47 /// <summary> 48 /// 【非必填】篩選條件樓層 49 /// </summary> 50 [JsonProperty("floor", NullValueHandling = NullValueHandling.Ignore)] 51 public string Floor { get; set; } 52 53 /// <summary> 54 /// 【非必填】根據paginationContextId返回構件ID列表 55 /// </summary> 56 [JsonProperty("paginationContextId", NullValueHandling = NullValueHandling.Ignore)] 57 public string PaginationContextId { get; set; } 58 59 /// <summary> 60 /// 【非必填】返回結果中paginationNo對應的頁碼構件ID項 61 /// </summary> 62 [JsonProperty("paginationNo", NullValueHandling = NullValueHandling.Ignore)] 63 public int? PaginationNo { get; set; } 64 65 /// <summary> 66 /// 【非必填】返回結果按照paginationSize分頁 67 /// </summary> 68 [JsonProperty("paginationSize", NullValueHandling = NullValueHandling.Ignore)] 69 public int? PaginationSize { get; set; } 70 71 /// <summary> 72 /// 【非必填】篩選條件房間id 73 /// </summary> 74 [JsonProperty("roomId", NullValueHandling = NullValueHandling.Ignore)] 75 public string RoomId { get; set; } 76 77 /// <summary> 78 /// 【非必填】XY座標軸方向對構件的篩選容忍度 79 /// </summary> 80 [JsonProperty("roomToleranceXY", NullValueHandling = NullValueHandling.Ignore)] 81 public RoomTolerance? RoomToleranceXY { get; set; } 82 83 /// <summary> 84 /// 【非必填】Z座標軸方向對構件的篩選容忍度 85 /// </summary> 86 [JsonProperty("roomToleranceZ", NullValueHandling = NullValueHandling.Ignore)] 87 public RoomTolerance? RoomToleranceZ { get; set; } 88 89 /// <summary> 90 /// 【非必填】篩選條件專業 91 /// </summary> 92 [JsonProperty("specialty", NullValueHandling = NullValueHandling.Ignore)] 93 public string Specialty { get; set; } 94 95 /// <summary> 96 /// 【非必填】篩選條件系統類型 97 /// </summary> 98 [JsonProperty("systemType", NullValueHandling = NullValueHandling.Ignore)] 99 public string SystemType { get; set; } 100 }
1 /// <summary> 2 /// 座標軸方向對構件的篩選容忍度 3 /// </summary> 4 public enum RoomTolerance 5 { 6 STRICT, 7 8 ORDINARY, 9 10 LENIENT 11 }
參數都是可選的,若是不設置,則默認不添加到請求中。
在BIMFACE的控制檯中能夠看到咱們上傳的文件列表,共計2個文件。模型狀態均爲轉換成功。
以「01_BIMFACE示例文件-Revit模型.rvt」爲例查詢其構建ID列表
查看結果中返回了構建ID列表。
若是使用 .dwg 二維文件進行測試則返回一下信息:unsupported operation:[please upgrade this databag to support specialty tree]
查詢知足條件的構件ID列表 ,只對三維模型適用。二維圖紙沒有目錄樹。
測試代碼以下:
// 查詢知足條件的構件ID列表 protected void btnGetFileElements_Click(object sender, EventArgs e) { FileConvertApi api = new FileConvertApi(); FileElementsGetResponse response = api.GetFileElements(txtAccessToken.Text, txtFileID.Text); txtResult.Text = response.Code.ToString2() + Environment.NewLine + response.Message.ToString2() + Environment.NewLine + response.Data.ToStringWith(","); }
查詢構建ID列表返回類 FileElementsGetResponse
/// <summary> /// 查詢知足條件的構件ID列表返回的結果類 /// </summary> public class FileElementsGetResponse : GeneralResponse<List<string>> { }