系列目录 【已更新最新开发文章,点击查看详细】
在《C#开发BIMFACE系列25 服务端API之获取模型数据9:获取楼层对应面积分区列表》一文中介绍了如何获取单个模型中单个楼层包含的面积分区列表。有了面积分区列表之后,即可查询单个面积分区的具体信息。
请求地址:GET https://api.bimface.com/data/v2/files/{fileId}/areas
说明:获取单个模型中单个面积分区包含的信息
参数:
请求 path(示例):https://api.bimface.com/data/v2/files/1211223382064960/areas/313467
请求 header(示例):"Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b"
HTTP响应示例(200):
{
"code" : "success",
"data" : {
"area" : 5.168684733047761E7,
"boundary" : "",
"id" : "313137",
"levelId" : "11",
"maxPt" : {
"x" : -4938.068482562385,
"y" : -3201.59397858169,
"z" : 0.0
},
"minPt" : {
"x" : -4938.068482562385,
"y" : -3201.59397858169,
"z" : 0.0
},
"name" : "dining room 4",
"perimeter" : 28802.013920728663,
"properties" : [ {
"group" : "dimension",
"items" : [ {
"code" : "perimeter",
"extension" : "object",
"key" : "perimeter",
"orderNumber" : 0,
"unit" : "mm",
"value" : 17200,
"valueType" : 2
} ]
} ],
"viewName" : "1 1"
},
"message" : ""
}
封装成对应的C#类如下:
/// <summary>
/// 获取单个面积分区信息返回的结果类
/// </summary>
[Serializable]
public class SingleModelSingleArea : GeneralResponse<Area>
{
}
其中 Area 类,请参考《C#开发BIMFACE系列25 服务端API之获取模型数据10:获取楼层对应面积分区列表》。
C#实现方法:
1 /// <summary>
2 /// 获取单个模型中单个面积分区信息
3 /// </summary>
4 /// <param name="accessToken">【必填】令牌</param>
5 /// <param name="fileId">【必填】代表该单模型的文件ID</param>
6 /// <param name="areaId">【必填】面积分区ID</param>
7 /// <returns></returns>
8 public virtual SingleModelSingleArea GetSingleModelSingleArea(string accessToken, long fileId, string areaId)
9 {
10 // GET https://api.bimface.com/data/v2/files/{fileId}/areas/{areaId}
11 string url = string.Format(BimfaceConstants.API_HOST + "/data/v2/files/{0}/areas/{1}", fileId, areaId);
12
13 BimFaceHttpHeaders headers = new BimFaceHttpHeaders();
14 headers.AddOAuth2Header(accessToken);
15
16 try
17 {
18 SingleModelSingleArea response;
19
20 HttpManager httpManager = new HttpManager(headers);
21 HttpResult httpResult = httpManager.Get(url);
22 if (httpResult.Status == HttpResult.STATUS_SUCCESS)
23 {
24 response = httpResult.Text.DeserializeJsonToObject<SingleModelSingleArea>();
25 }
26 else
27 {
28 response = new SingleModelSingleArea
29 {
30 Message = httpResult.RefText
31 };
32 }
33
34 return response;
35 }
36 catch (Exception ex)
37 {
38 throw new Exception("[获取单个面积分区信息]发生异常!", ex);
39 }
40 }
其中调用到的 httpManager.Get() 方法,请参考《C# HTTP系列》
测试
在BIMFACE的控制台中可以看到我们上传的文件列表,模型状态均为转换成功。
使用“bimface_2018_mdv_room.rvt”为例测试上述方法。
在《C#开发BIMFACE系列25 服务端API之获取模型数据10:获取楼层对应面积分区列表》中返回了2个面积分区ID,分别是1092832与1092841。
1092841完整的面积分区信息如下:
success
[area=4333552.00744229,
boundary={"version":"2.0",
"loops":[[[{"z":2999.9998798520546,"y":-3201.5938503598827,"x":4505.6454184675295},
{"z":2999.9998798520546,"y":-3201.5938503598904,"x":7001.9312370150637}
],
[{"z":2999.9998798520546,"y":-3302.5938463149096,"x":7001.9312370150637},
{"z":2999.9998798520546,"y":-1465.5939198856749,"x":7001.9312370150674}
],
[{"z":2999.9998798520546,"y":-1465.5939198856749,"x":7001.9312370150665},
{"z":2999.9998798520546,"y":-1465.5939198856668,"x":4505.6454184675331}
],
[{"z":2999.9998798520546,"y":-1465.5939198856677,"x":4505.6454184675331},
{"z":2999.9998798520546,"y":-3302.5938463149018,"x":4505.64541846753}
]
]
]
},
id=1092841,
levelId=,
maxPt=[x=7001.93123701507, y=-1465.59391988567, z=2999.99987985205],
minPt=[x=4505.64541846753, y=-3302.59384631491, z=2999.99987985205],
name=面积 3,
perimeter=8104.57151246125,
properties=[group=其他,
items=[code=, extension=, key=面积类型, orderNumber=,unit=,value=建筑公共面积,valueType=4]
]
[group=尺寸标注,
items=[code=, extension=, key=周长, orderNumber=,unit=mm,value=8105,valueType=2]
[code=, extension=, key=计算高度, orderNumber=,unit=mm,value=0,valueType=2]
[code=, extension=, key=面积, orderNumber=,unit=m²,value=4,valueType=2]
]
[group=标识数据,
items=[code=, extension=, key=名称, orderNumber=,unit=,value=面积,valueType=3]
[code=, extension=, key=图像, orderNumber=,unit=,value=,valueType=4]
[code=, extension=, key=注释, orderNumber=,unit=,value=,valueType=3]
[code=, extension=, key=编号, orderNumber=,unit=,value=3,valueType=3]
]
[group=限制条件,
items=[code=, extension=, key=标高, orderNumber=,unit=,value=Level 2,valueType=4]
],
viewName=
]
测试代码如下:
// 获取单个面积分区信息
protected void btnGetSingleModelSingleArea_Click(object sender, EventArgs e)
{
long fileId = txtFileID.Text.Trim().ToLong();
string areaId = txtAreaId.Text.Trim();
FileConvertApi api = new FileConvertApi();
SingleModelSingleArea response = api.GetSingleModelSingleArea(txtAccessToken.Text, fileId, areaId);
txtResult.Text = response.Code.ToString2()
+ Environment.NewLine
+ response.Message.ToString2()
+ Environment.NewLine
+ response.Data;
}
系列目录 【已更新最新开发文章,点击查看详细】