solidity calldata 详解(C二次开发BIMFACE系列16服务端API查询满足条件的构件ID列表)(1)

源文件/模型转换完成之后,可以获取模型的具体数据。本篇介绍根据文件ID查询满足条件的构件ID列表。

请求地址:GET https://api.bimface.com/data/v2/files/{fileId}/elementIds

说明:根据六个维度(专业,系统类型,楼层,构件类型,族,族类型)获取对应的构件ID列表,任何维度都是可选的。

同时,也支持根据空间关系从房间计算出房间内的构件ID列表。

参数:

solidity calldata 详解(C二次开发BIMFACE系列16服务端API查询满足条件的构件ID列表)(2)

solidity calldata 详解(C二次开发BIMFACE系列16服务端API查询满足条件的构件ID列表)(3)

请求 path(示例):https://api.bimface.com/data/v2/files/1211223382064960/elementIds

请求 header(示例):"Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b"

HTTP响应示例(200):

{ "code": "success", "message": null, "data": [ "1107237", "1109326", "1107234", "1109327", "1107235", "1107239", "1109329", "1107236", "1109325", "1107238", "1109328" ] }

C#实现方法:

/// <summary> /// 查询满足条件的构件ID列表 /// </summary> /// <param name="accessToken">令牌</param> /// <param name="fileId">文件ID</param> /// <param name="request">请求参数对象</param> /// <returns></returns> public virtual FileElementsGetResponse GetFileElements(string accessToken, string fileId, FileElementsGetRequest request = null) { // GET https://api.bimface.com/data/v2/files/{fileId}/elementIds string url = string.Format(BimfaceConstants.API_HOST "/data/v2/files/{0}/elementIds", fileId); BimFaceHttpHeaders headers = new BimFaceHttpHeaders(); headers.AddOAuth2Header(accessToken); string data = string.Empty; if (request != null) { data = request.SerializeToJson(); } try { FileElementsGetResponse response; HttpManager httpManager = new HttpManager(headers); HttpResult httpResult = httpManager.Get(url, data); if (httpResult.Status == HttpResult.STATUS_SUCCESS) { response = httpResult.Text.DeserializeJsonToObject<FileElementsGetResponse>(); } else { response = new FileElementsGetResponse { Message = httpResult.RefText }; } return response; } catch (Exception ex) { throw new Exception("[查询满足条件的构件ID列表]发生异常!", ex); } }

封装的其他请求参数类 FileElementsGetRequest

/// <summary> /// 查询满足条件的构件ID列表请求参数类 /// </summary> [Serializable] public class FileElementsGetRequest { public FileElementsGetRequest() { CategoryId = null; Family = null; FamilyType = null; Floor = null; PaginationContextId = null; PaginationNo = null; PaginationSize = null; RoomId = null; RoomToleranceXY = null; RoomToleranceZ = null; Specialty = null; SystemType = null; } ///// <summary> ///// 【必填】代表该单模型的文件ID ///// </summary> //[JsonProperty("fileId")] //public long FileId { get; set; } /// <summary> /// 【非必填】筛选条件构件类型id /// </summary> [JsonProperty("categoryId",NullValueHandling = NullValueHandling.Ignore)] public string CategoryId { get; set; } /// <summary> /// 【非必填】筛选条件族 /// </summary> [JsonProperty("family", NullValueHandling = NullValueHandling.Ignore)] public string Family { get; set; } /// <summary> /// 【非必填】筛选条件族类型 /// </summary> [JsonProperty("familyType", NullValueHandling = NullValueHandling.Ignore)] public string FamilyType { get; set; } /// <summary> /// 【非必填】筛选条件楼层 /// </summary> [JsonProperty("floor", NullValueHandling = NullValueHandling.Ignore)] public string Floor { get; set; } /// <summary> /// 【非必填】根据paginationContextId返回构件ID列表 /// </summary> [JsonProperty("paginationContextId", NullValueHandling = NullValueHandling.Ignore)] public string PaginationContextId { get; set; } /// <summary> /// 【非必填】返回结果中paginationNo对应的页码构件ID项 /// </summary> [JsonProperty("paginationNo", NullValueHandling = NullValueHandling.Ignore)] public int? PaginationNo { get; set; } /// <summary> /// 【非必填】返回结果按照paginationSize分页 /// </summary> [JsonProperty("paginationSize", NullValueHandling = NullValueHandling.Ignore)] public int? PaginationSize { get; set; } /// <summary> /// 【非必填】筛选条件房间id /// </summary> [JsonProperty("roomId", NullValueHandling = NullValueHandling.Ignore)] public string RoomId { get; set; } /// <summary> /// 【非必填】XY坐标轴方向对构件的筛选容忍度 /// </summary> [JsonProperty("roomToleranceXY", NullValueHandling = NullValueHandling.Ignore)] public RoomTolerance? RoomToleranceXY { get; set; } /// <summary> /// 【非必填】Z坐标轴方向对构件的筛选容忍度 /// </summary> [JsonProperty("roomToleranceZ", NullValueHandling = NullValueHandling.Ignore)] public RoomTolerance? RoomToleranceZ { get; set; } /// <summary> /// 【非必填】筛选条件专业 /// </summary> [JsonProperty("specialty", NullValueHandling = NullValueHandling.Ignore)] public string Specialty { get; set; } /// <summary> /// 【非必填】筛选条件系统类型 /// </summary> [JsonProperty("systemType", NullValueHandling = NullValueHandling.Ignore)] public string SystemType { get; set; } }

/// <summary> /// 坐标轴方向对构件的筛选容忍度 /// </summary> public enum RoomTolerance { STRICT, ORDINARY, LENIENT }

参数都是可选的,如果不设置,则默认不添加到请求中。

测试

在BIMFACE的控制台中可以看到我们上传的文件列表,共计2个文件。模型状态均为转换成功。

solidity calldata 详解(C二次开发BIMFACE系列16服务端API查询满足条件的构件ID列表)(4)

查看结果中返回了构建ID列表。

如果使用 .dwg 二维文件进行测试则返回一下信息:unsupported operation:[please upgrade this databag to support specialty tree]

solidity calldata 详解(C二次开发BIMFACE系列16服务端API查询满足条件的构件ID列表)(5)

查询满足条件的构件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>> { }


系列文章主要技术:BIM、轻量化引擎、BIMFACE、BIMFACE二次开发、C#、.NET、二次开发、RESTful API、WebAPI


#三孩生育政策配套支持措施来了#

#辱母刺杀案于欢接父亲出狱#

#作家紫金陈上1818黄金眼维权#

#央视网:警惕“熊孩子”被污名化#

#梁建章:可以给多胎家庭购房补贴#

,