快捷搜索:  汽车  科技

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)/// <summary> /// 获取三维视点或二维视图列表的返回结果类 /// </summary> [Serializable] public class SingleModelViews : GeneralResponse<List<ViewInfo>> { }引用的 ViewInfo 类{ "code" : "success" "data" : [ { "cropBox" : [ -12147.804809235151 -19279.554054815613 -30480.0 22637.545576143948 6805.089759789783 30480.0 ] "elevation" : 0.0

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(1)

本篇主要介绍如何获取一个模型中包含的三维视点或二维视图列表。

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

说明:获取单模型中包含的三维视点或二维视图列表。

参数:

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(2)

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

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

HTTP响应示例(200):

{ "code" : "success" "data" : [ { "cropBox" : [ -12147.804809235151 -19279.554054815613 -30480.0 22637.545576143948 6805.089759789783 30480.0 ] "elevation" : 0.0 "id" : "312" "levelId" : "312" "name" : "Level 1" "outline" : [ -146.52900292249365 -215.01048476685295 240.3331231070219 110.78415780710446 ] "preview" : { "height" : 0 "path" : "path" "width" : 0 } "thumbnails" : [ "m.bimface.com/9b711803a43b92d871cde346b63e5019/resource/thumbnails/312/312.96x96.png" ] "viewPoint" : { "origin" : [ 0.0 ] "rightDirection" : [ 0.0 ] "scale" : 0 "upDirection" : [ 0.0 ] "viewDirection" : [ 0.0 ] } "viewType" : "FloorPlain" } ] "message" : "" }

该返回结果的结构比较复杂,封装成如下的C#类:

/// <summary> /// 获取三维视点或二维视图列表的返回结果类 /// </summary> [Serializable] public class SingleModelViews : GeneralResponse<List<ViewInfo>> { }

引用的 ViewInfo 类

/// <summary> /// 三维视点或二维视图 /// </summary> [Serializable] public class ViewInfo { /// <summary> /// 样例:[ -12147.804809235151 -19279.554054815613 -30480.0 22637.545576143948 6805.089759789783 30480.0 ] /// </summary> [JsonProperty("cropBox")] public double?[] CropBox { get; set; } /// <summary> /// 样例:0.0 /// </summary> [JsonProperty("elevation")] public double? Elevation { get; set; } /// <summary> /// 样例:"312" /// </summary> [JsonProperty("id")] public string Id { get; set; } /// <summary> /// 样例:"312" /// </summary> [JsonProperty("levelId")] public string LevelId { get; set; } /// <summary> /// 样例:[ -146.52900292249365 -215.01048476685295 240.3331231070219 110.78415780710446 ] /// </summary> [JsonProperty("outline")] public double?[] Outline { get; set; } [JsonProperty("preview")] public Preview Preview { get; set; } /// <summary> /// 缩略图数组。样例:[ "m.bimface.com/9b711803a43b92d871cde346b63e5019/resource/thumbnails/312/312.96x96.png" ] /// </summary> [JsonProperty("thumbnails")] public string[] Thumbnails { get; set; } [JsonProperty("viewPoint")] public ViewPoint ViewPoint { get; set; } [JsonProperty("viewType")] public string ViewType { get; set; } /// <summary>返回表示当前对象的字符串。</summary> /// <returns>表示当前对象的字符串。</returns> public override string ToString() { return string.Format("[cropBox={0} elevation={1} width={2} Id={2} levelId={3} Outline={4} preview={5} thumbnails={6} viewPoint={7} viewType={8}]" CropBox.ToStringWith(" ") Elevation Id LevelId Outline.ToStringWith(" ") Preview Thumbnails.ToStringWith(" ") ViewPoint ViewType); } }

其中引用的 Preview 类

[Serializable] public class Preview { /// <summary> /// 样例:0 /// </summary> [JsonProperty("height")] public int? Height { get; set; } [JsonProperty("path")] public string Path { get; set; } /// <summary> /// 样例:0 /// </summary> [JsonProperty("width")] public int? Width { get; set; } /// <summary>返回表示当前对象的字符串。</summary> /// <returns>表示当前对象的字符串。</returns> public override string ToString() { return string.Format("[height={0} path={1} width={2}]" Height Path Width); } }

ViewPoint 类

[Serializable] public class ViewPoint { /// <summary> /// 样例 : [ 0.0 ] /// </summary> [JsonProperty("origin")] public double?[] Origin { get; set; } /// <summary> /// 样例 : [ 0.0 ] /// </summary> [JsonProperty("rightDirection")] public double?[] RightDirection { get; set; } /// <summary> /// 样例 : [ 0.0 ] /// </summary> [JsonProperty("scale")] public int? Scale { get; set; } /// <summary> /// 样例 : [ 0.0 ] /// </summary> [JsonProperty("upDirection")] public double?[] UpDirection { get; set; } /// <summary> /// 样例 : [ 0.0 ] /// </summary> [JsonProperty("viewDirection")] public double?[] ViewDirection { get; set; } /// <summary>返回表示当前对象的字符串。</summary> /// <returns>表示当前对象的字符串。</returns> public override string ToString() { return String.Format("[origin={0} rightDirection={1} scale={2}, upDirection={3} viewDirection={4}]" Origin.ToStringWith(" ") RightDirection.ToStringWith(" ") Scale UpDirection.ToStringWith(" ") ViewDirection.ToStringWith(" ")); } }

C#实现方法:

/// <summary> /// 获取三维视点或二维视图列表 /// </summary> /// <param name="accessToken">【必填】令牌</param> /// <param name="fileId">【必填】代表该单模型的文件ID</param> /// <returns></returns> public virtual SingleModelViews GetSingleModelViews(string accessToken long fileId) { // GET https://api.bimface.com/data/v2/files/{fileId}/views string url = string.Format(BimfaceConstants.API_HOST "/data/v2/files/{0}/views" fileId); BimFaceHttpHeaders headers = new BimFaceHttpHeaders(); headers.AddOAuth2Header(accessToken); try { SingleModelViews response; HttpManager httpManager = new HttpManager(headers); HttpResult httpResult = httpManager.Get(url); if (httpResult.Status == HttpResult.STATUS_SUCCESS) { response = httpResult.Text.DeserializeJsonToObject<SingleModelViews>(); } else { response = new SingleModelViews { Message = httpResult.RefText }; } return response; } catch (Exception ex) { throw new Exception("[获取楼层对应面积分区列表]发生异常!" ex); } }

其中调用到的 httpManager.Post() 方法,请参考《C# HTTP系列》

https://www.cnblogs.com/SavionZhang/p/11422481.html

测试

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

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(3)

使用“bimface_2018_mdv_room.rvt”为例测试上述方法。

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(4)

完整的视图列表为

success [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=382617 Id=382617 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/382617/382617.png width=1024 ] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/382617/382617.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1 ] viewType=DrawingSheet ] ] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=503701 Id=503701 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/503701/503701.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/503701/503701.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=958184 Id=958184 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/958184/958184.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/958184/958184.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=958251 Id=958251 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/958251/958251.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/958251/958251.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=959135 Id=959135 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/959135/959135.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/959135/959135.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=959510 Id=959510 levelId= Outline=2.49999989974552 -73.1185993073838 842.499966258321 592.999976250742 preview=[height=812 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/959510/959510.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/959510/959510.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=1080884 Id=1080884 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/1080884/1080884.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/1080884/1080884.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=1081048 Id=1081048 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/1081048/1081048.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/1081048/1081048.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]] [fileId= portAndViews= viewInfo=[cropBox=-30479.998046875 -30479.998046875 -304800 30479.998046875 30479.998046875 -30.4799995422363 elevation=0 width=1081066 Id=1081066 levelId= Outline=2.49999989974552 -0.999999959964061 842.499966258321 592.999976250742 preview=[height=724 path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/1081066/1081066.png width=1024] thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails/1081066/1081066.96x96.png viewPoint=[origin=0 0 0 rightDirection=1 0 0 scale=1, upDirection=0 1 0 viewDirection=0 0 1] viewType=DrawingSheet]]

测试代码如下:

// 获取三维视点或二维视图列表 protected void btnGetSingleModelViews_Click(object sender EventArgs e) { long fileId = txtFileID.Text.Trim().ToLong(); FileConvertApi api = new FileConvertApi(); SingleModelViews response = api.GetSingleModelViews(txtAccessToken.Text fileId); txtResult.Text = response.Code.ToString2() Environment.NewLine response.Message.ToString2() Environment.NewLine response.Data.ToStringLine(); }


C#二次开发BIMFACE系列27 服务端API之获取构件分类树

原创2021-06-15 09:16·张传宁IT讲堂

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(5)

 BIMFACE官方示例中,加载三维模型后,模型浏览器中左上角默认提供了“目录树”的功能,清晰地展示了模型的完整构成及上下级关系。

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(6)

本篇介绍如何获取单个模型的构件分类树信息。

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

说明:单模型构件分类树 treeType 接受两个值:default 和 customized,默认为 default。

v参数用来区别 treeType 为 default 时返回树的格式, customized总是返回格式2.0的构件树。

参数:

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(7)

v参数用来区别 treeType 为 default 时返回树的格式, customized总是返回格式2.0的构件树。

当 treeType 为"customized"时,desiredHierarchy 表示了筛选树的层次 可选值有building systemType specialty floor category family familyType,如:desiredHierarchy=specialty systemtype。

customizedNodeKeys:用来指定筛选树每个维度用id或者是name作为唯一标识 如"floor":"id"。

请求2.0的默认分类树(floor category family familyType)

请求 path(示例):
https://api.bimface.com/data/v2/files/1211223382064960/tree?v=2.0

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

请求 body(示例):可以为空,不传递。

HTTP响应示例(200):

{ "code": "success" "message": null "data": [ { "actualName": "1F" "data": null "elementCount": 18 "id": "694" "items": [ { "actualName": "栏杆扶手" "data": null "elementCount": 18 "id": "-2000126" "items": [ { "actualName": "栏杆扶手" "data": null "elementCount": 18 "id": "" "items": [ { "actualName": "栏杆" "data": null "elementCount": 1 "id": null "items": [] "name": "栏杆" "type": "familyType" } ] "name": "栏杆扶手" "type": "family" } ] "name": "栏杆扶手" "type": "category" } ] "name": "1F" "type": "floor" } ] }

返回的结果结构比较复杂,封装成对应的C#类如下:

/// <summary> /// 获取单个模型的构件分类树(2.0的默认分类树 floor category family familyType)返回的结果类(默认模式) /// </summary> [Serializable] public class SingleModelTree : GeneralResponse<List<TreeItem>> { }

调用的 TreeItem 类

[Serializable] public class TreeItem { /// <summary> /// 项的名称 /// </summary> [JsonProperty("actualName")] public string ActualName { get; set; } [JsonProperty("data")] public string Data { get; set; } [JsonProperty("elementCount")] public int? ElementCount { get; set; } [JsonProperty("id")] public string Id { get; set; } [JsonProperty("items")] public TreeItem[] Items { get; set; } [JsonProperty("name")] public string Name { get; set; } /// <summary> /// 例如:familyType、family、category /// </summary> [JsonProperty("type")] public string Type { get; set; } /// <summary>返回表示当前对象的字符串。</summary> /// <returns>表示当前对象的字符串。</returns> public override string ToString() { return String.Format("[actualName={0} data={1} elementCount={2} id={3} items={4} name={5} type={6}]" ActualName Data ElementCount Id Items.ToStringLine() Name Type); } }

请注意 TreeItem 类中的 public TreeItem[] Items { get; set; } 属性,类型是该类本身。属于递归引用。

Newtonsoft.Json.dll 默认支持递归引用类的序列化与反序列化。

C#实现方法:

/// <summary> /// 获取单个模型中构件的默认分类树 /// </summary> /// <param name="accessToken">【必填】令牌</param> /// <param name="fileId">【必填】代表该单模型的文件ID</param> /// <param name="v">【非必填】用来区别treeType为default时返回树的格式</param> /// <param name="request">【非必填】其他过滤参数类对象</param> /// <returns></returns> public virtual SingleModelTree GetSingleModelTreeByDefault(string accessToken long fileId string v = "2.0" FileTreeRequestBody request = null) { //return GetSingleModelTree(accessToken fileId TreeType.Default v request); /* 单模型构件分类树 (1)treeType 接受两个值:default 和 customized,默认为 default。 (2)v 参数用来区别 treeType 为 default 时返回树的格式 customized 总是返回格式2.0的构件树。 (3)当 treeType 为"customized"时,FileTreeRequestBody 类的 desiredHierarchy 属性 表示了筛选树的层次 可选值有building systemType specialty floor category family familyType, 如:desiredHierarchy=specialty systemtype。 customizedNodeKeys: 用来指定筛选树每个维度用id或者是name作为唯一标识 如"floor":"id" */ // POST https://api.bimface.com/data/v2/files/{fileId}/tree string url = string.Format(BimfaceConstants.API_HOST "/data/v2/files/{0}/tree?treeType=default" fileId); if (!string.IsNullOrWhiteSpace(v)) { url = url "&v=" v; } string data = string.Empty; if (request != null) { data = request.SerializeToJson(); } BimFaceHttpHeaders headers = new BimFaceHttpHeaders(); headers.AddOAuth2Header(accessToken); try { SingleModelTree response; HttpManager httpManager = new HttpManager(headers); HttpResult httpResult = httpManager.Post(url data); if (httpResult.Status == HttpResult.STATUS_SUCCESS) { response = httpResult.Text.DeserializeJsonToObject<SingleModelTree>(); } else { response = new SingleModelTree { Message = httpResult.RefText }; } return response; } catch (Exception ex) { throw new Exception("[获取单个模型中构件的默认分类树]发生异常!" ex); } }

其中调用到的 httpManager.Post() 方法,请参考《C# HTTP系列》

https://www.cnblogs.com/SavionZhang/p/11422481.html

测试:

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

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(8)

使用“A4.rvt”为例测试上述方法。

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(9)

完整的分类树为:

success [ { "actualName": "标高 1" "data": null "elementCount": 4 "id": "311" "items": [ { "actualName": "墙" "data": null "elementCount": 4 "id": "-2000011" "items": [ { "actualName": "基本墙" "data": null "elementCount": 4 "id": "" "items": [ { "actualName": "常规 - 200mm" "data": null "elementCount": 4 "id": "398" "items": [] "name": "常规 - 200mm" "type": "familyType" } ] "name": "基本墙" "type": "family" } ] "name": "墙" "type": "category" } ] "name": "标高 1" "type": "floor" } ]

测试代码如下:

// 获取构件分类树(默认) protected void btnGetSingleModelTreeByDefault_Click(object sender EventArgs e) { long fileId = txtFileID.Text.Trim().ToLong(); FileConvertApi api = new FileConvertApi(); SingleModelTree response = api.GetSingleModelTreeByDefault(txtAccessToken.Text fileId); txtResult.Text = response.Code.ToString2() Environment.NewLine response.Message.ToString2() Environment.NewLine response.Data.ToStringLine(); }

请求自定义树(floor category family familyType)

请求 path(示例):
https://api.bimface.com/data/v2/files/1211223382064960/tree?v=2.0&treeType=customized

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

请求 body(示例):

{ "desiredHierarchy": [ "category" "family" ] "customizedNodeKeys": { "category": "name" } }

请求体不能为 NULL ,必须传递值。 否则请求失败,提示 system.error. customized tree request body is null

HTTP响应示例(200):

{ "code": "success" "message": null "data": { "items": [ { "actualName": "专用设备" "data": null "elementCount": 6 "id": "-2001350" "items": [ { "actualName": "投影仪-基于天花板 3D" "data": null "elementCount": 3 "id": "" "items": [ ] "name": "投影仪-基于天花板 3D" "type": "family" } { "actualName": "投影屏幕-基于天花板 3D" "data": null "elementCount": 3 "id": "" "items": [ ] "name": "投影屏幕-基于天花板 3D" "type": "family" } ] "name": "卫浴装置" "type": "category" } ] "root": "category" } }

返回的结果结构比较复杂,封装成对应的C#类如下:

/// <summary> /// 获取单个模型的构件分类树(自定义树floor category family familyType)返回的结果类 /// </summary> [Serializable] public class SingleModelTreeByCustomized : GeneralResponse<SingleModelTreeByCustomized> { [JsonProperty("root")] public string Root { get; set; } [JsonProperty("items")] public TreeItem[] Items { get; set; } /// <summary>返回表示当前对象的字符串。</summary> /// <returns>表示当前对象的字符串。</returns> public override string ToString() { return String.Format("[root={0} items={1}]" Root Items.ToStringLine()); } }

C#实现方法:

/// <summary> /// 获取单个模型中构件的自定义分类树 /// </summary> /// <param name="accessToken">【必填】令牌</param> /// <param name="fileId">【必填】代表该单模型的文件ID</param> /// <param name="v">【非必填】用来区别treeType为default时返回树的格式</param> /// <param name="request">【非必填】其他过滤参数类对象</param> /// <returns></returns> public virtual SingleModelTreeByCustomized GetSingleModelTreeByCustomized(string accessToken long fileId string v = "2.0" FileTreeRequestBody request = null) { //return GetSingleModelTree(accessToken fileId TreeType.Default v request); /* 单模型构件分类树 (1)treeType 接受两个值:default 和 customized,默认为 default。 (2)v 参数用来区别 treeType 为 default 时返回树的格式 customized 总是返回格式2.0的构件树。 (3)当 treeType 为"customized"时,FileTreeRequestBody 类的 desiredHierarchy 属性 表示了筛选树的层次 可选值有building systemType specialty floor category family familyType, 如:desiredHierarchy=specialty systemtype。 customizedNodeKeys: 用来指定筛选树每个维度用id或者是name作为唯一标识 如"floor":"id" */ // POST https://api.bimface.com/data/v2/files/{fileId}/tree string url = string.Format(BimfaceConstants.API_HOST "/data/v2/files/{0}/tree?treeType=customized" fileId); if (!string.IsNullOrWhiteSpace(v)) { url = url "&v=" v; } string data = string.Empty; if (request != null) { data = request.SerializeToJson(); } BimFaceHttpHeaders headers = new BimFaceHttpHeaders(); headers.AddOAuth2Header(accessToken); try { SingleModelTreeByCustomized response; HttpManager httpManager = new HttpManager(headers); HttpResult httpResult = httpManager.Post(url data); if (httpResult.Status == HttpResult.STATUS_SUCCESS) { response = httpResult.Text.DeserializeJsonToObject<SingleModelTreeByCustomized>(); } else { response = new SingleModelTreeByCustomized { Message = httpResult.RefText }; } return response; } catch (Exception ex) { throw new Exception("[获取单个模型中构件的自定义分类树]发生异常!" ex); } }

测试:

同样使用“A4.rvt”为例测试上述方法。

u3d开发入门教程(C二次开发BIMFACE系列28服务端API之获取三维视点或二维视图列表)(10)

完整的分类树为:

success [root=单体 items=[actualName= data= elementCount=4 id=0 items=[actualName= data= elementCount=4 id=0 items=[actualName= data= elementCount=4 id=0 items=[actualName=标高 1 data= elementCount=4 id=311 items=[actualName=墙 data= elementCount=4 id=-2000011 items=[actualName=基本墙 data= elementCount=4 id= items=[actualName=常规 - 200mm data= elementCount=4 id=398 items= name=常规 - 200mm type=familyType ] name=基本墙 type=family ] name=墙 type=category ] name=标高 1 type=floor ] name=未设专业 type=specialty ] name=未设系统类型 type=systemType ] name=未设单体 type=building ] ]

界面上的筛选树的层次是过滤条件,主要用于筛选 type 属性。

测试代码如下:

// 获取构件分类树(自定义) protected void btnGetSingleModelTreeByCustomized_Click(object sender EventArgs e) { long fileId = txtFileID.Text.Trim().ToLong(); List<string> lstDesiredHierarchy = new List<string>(); if (chkTreeBuilding.Checked) { lstDesiredHierarchy.Add("building"); } if (chkTreeSystemType.Checked) { lstDesiredHierarchy.Add("systemType"); } if (chkTreeSpecialty.Checked) { lstDesiredHierarchy.Add("specialty"); } if (chkTreeFloor.Checked) { lstDesiredHierarchy.Add("floor"); } if (chkTreeCategory.Checked) { lstDesiredHierarchy.Add("category"); } if (chkTreeFamily.Checked) { lstDesiredHierarchy.Add("family"); } if (chkTreeFamilyType.Checked) { lstDesiredHierarchy.Add("familyType"); } FileTreeRequestBody request = new FileTreeRequestBody(); request.DesiredHierarchy = lstDesiredHierarchy.ToArray();// new[] { "building" "systemType" "specialty" "floor" "category" "family" "familyType" }; request.CustomizedNodeKeys = new Dictionary<string string> { { "category" "name" } }; FileConvertApi api = new FileConvertApi(); SingleModelTreeByCustomized response = api.GetSingleModelTreeByCustomized(txtAccessToken.Text fileId "2.0" request); txtResult.Text = response.Code.ToString2() Environment.NewLine response.Message.ToString2() Environment.NewLine response.Data; }


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


欢迎关注、点赞、评论、转发,每天都能获取优质内容。

回复101,或者私信作者获取《BIMFACE二次开发C#版SDK》。


#国足3-1叙利亚 晋级12强赛#

#世预赛12强赛分档:国足第四档#

#普京回应涉台湾问题#

#C罗双响 葡萄牙3-0匈牙利#

#拜登称普京是值得尊敬的对手#

猜您喜欢: