系列目录 【已更新最新开发文章,点击查看详细】
BIMFACE平台提供了服务端“获取修改构件属性差异”API,其返回的结果也是一个列表,仅针对修改的构件(不包含新增、删除的构件),是指对于一个修改过的构件ID,其修改前后分别新增、删除了哪些属性,或是属性值发生了变化。
请求地址:GET https://api.bimface.com/data/v2/comparisons/{comparisonId}/elementChange
参数:
请求 path(示例):https://api.bimface.com/data/v2/comparisons/1136906400211168/elementChange?followingElementId=296524&followingFileId=1136893002033344&previousElementId=296524&previousFileId=1136239003943104
请求 header(示例):"Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b"
HTTP响应示例(200):
{
"code" : "success",
"data" : {
"_A" : "string",
"_B" : "string",
"changeAttributes" : [ {
"_A" : {
"key" : "key",
"unit" : "unit",
"value" : "value"
},
"_B" : {
"key" : "key",
"unit" : "unit",
"value" : "value"
}
} ],
"changeQuantities" : [ {
"_A" : {
"code" : "code",
"desc" : "desc",
"name" : "name",
"qty" : ,
"unit" : "unit"
},
"_B" : {
"code" : "code",
"desc" : "desc",
"name" : "name",
"qty" : ,
"unit" : "unit"
}
} ],
"deleteAttributes" : [ {
"key" : "key",
"unit" : "unit",
"value" : "value"
} ],
"deleteQuantities" : [ {
"code" : "code",
"desc" : "desc",
"name" : "name",
"qty" : ,
"unit" : "unit"
} ],
"newAttributes" : [ {
"key" : "key",
"unit" : "unit",
"value" : "value"
} ],
"newQuantities" : [ {
"code" : "code",
"desc" : "desc",
"name" : "name",
"qty" : ,
"unit" : "unit"
} ]
},
"message" : ""
}
C#实现方法:
/// <summary>
/// 获取模型构件对比差异
/// </summary>
/// <param name="accessToken">【必填】令牌</param>
/// <param name="compareId">【必填】对比ID</param>
/// <param name="followingFileId">【必填】变更后的文件ID</param>
/// <param name="followingElementId">【必填】变更后的文件的构件ID</param>
/// <param name="previousFileId">【必填】变更前的文件ID</param>
/// <param name="previousElementId">【必填】变更前的文件的构件ID</param>
/// <returns></returns>
public virtual ModelCompareChangeResponse GetModelCompareChange(string accessToken, long compareId,
long followingFileId, string followingElementId, long previousFileId, string previousElementId)
{
// GET https: //api.bimface.com/data/v2/comparisons/{comparisonId}/elementChange
string url = string.Format(BimfaceConstants.API_HOST + "/data/v2/comparisons/{0}/elementChange", compareId);
url += "?followingFileId=" + followingFileId;
url += "&followingElementId=" + followingElementId;
url += "&previousFileId=" + previousFileId;
url += "&previousElementId=" + previousElementId; BimFaceHttpHeaders headers = new BimFaceHttpHeaders();
headers.AddOAuth2Header(accessToken); try
{
ModelCompareChangeResponse response; HttpManager httpManager = new HttpManager(headers);
HttpResult httpResult = httpManager.Get(url);
if (httpResult.Status == HttpResult.STATUS_SUCCESS)
{
response = httpResult.Text.DeserializeJsonToObject<ModelCompareChangeResponse>();
}
else
{
response = new ModelCompareChangeResponse
{
Message = httpResult.RefText
};
} return response;
}
catch (Exception ex)
{
throw new Exception("[获取模型构件对比差异]发生异常!", ex);
}
}
代码中使用的 HttpManager 类请参考我的博客文章《C# HTTP系列 HttpWebRequest 与 HttpWebResponse》。
返回类型 ModelCompareChangeResponse 类如下:
/// <summary>
/// 获取模型构件对比差异的响应类
/// </summary>
public class ModelCompareChangeResponse : GeneralResponse<ModelCompareChange>
{ } /// <summary>
/// 模型构件对比差异类
/// </summary>
public class ModelCompareChange
{
/// <summary>
/// 变化图元前一个版本的ID
/// </summary>
[JsonProperty("_A", NullValueHandling = NullValueHandling.Ignore)]
public string A { get; set; } /// <summary>
/// 变化图元后一个版本的ID
/// </summary>
[JsonProperty("_B", NullValueHandling = NullValueHandling.Ignore)]
public string B { get; set; } /// <summary>
/// 变更的构建属性集合
/// </summary> [JsonProperty("changeAttributes", NullValueHandling = NullValueHandling.Ignore)]
public ChangeAttributes[] ChangeAttributes { get; set; } /// <summary>
/// 变更的工程量集合
/// </summary> [JsonProperty("changeQuantities", NullValueHandling = NullValueHandling.Ignore)]
public ChangeQuantities[] ChangeQuantities { get; set; } /// <summary>
/// 删除的构建属性集合
/// </summary> [JsonProperty("deleteAttributes", NullValueHandling = NullValueHandling.Ignore)]
public Attribute[] DeleteAttributes { get; set; } /// <summary>
/// 删除的工程量集合
/// </summary> [JsonProperty("deleteQuantities", NullValueHandling = NullValueHandling.Ignore)]
public Quantity[] DeleteQuantities { get; set; } /// <summary>
/// 新增的构建属性集合
/// </summary> [JsonProperty("newAttributes", NullValueHandling = NullValueHandling.Ignore)]
public Attribute[] NewAttributes { get; set; } /// <summary>
/// 新增的工程量集合
/// </summary> [JsonProperty("newQuantities", NullValueHandling = NullValueHandling.Ignore)]
public Quantity[] NewQuantities { get; set; }
} /// <summary>
/// 变更的构建属性
/// </summary>
public class ChangeAttributes
{
/// <summary>
/// 前一个版本
/// </summary>
[JsonProperty("_A", NullValueHandling = NullValueHandling.Ignore)]
public Attribute A { get; set; } /// <summary>
/// 后一个版本
/// </summary>
[JsonProperty("_B", NullValueHandling = NullValueHandling.Ignore)]
public Attribute B { get; set; }
} /// <summary>
/// 变更的工程量
/// </summary>
public class ChangeQuantities
{
/// <summary>
/// 前一个版本
/// </summary>
[JsonProperty("_A", NullValueHandling = NullValueHandling.Ignore)]
public Quantity A { get; set; } /// <summary>
/// 后一个版本
/// </summary>
[JsonProperty("_B", NullValueHandling = NullValueHandling.Ignore)]
public Quantity B { get; set; }
} /// <summary>
/// 构建属性
/// </summary>
public class Attribute
{
[JsonProperty("key", NullValueHandling = NullValueHandling.Ignore)]
public string Key { get; set; } [JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)]
public string Value { get; set; } [JsonProperty("unit", NullValueHandling = NullValueHandling.Ignore)]
public string Unit { get; set; }
} /// <summary>
/// 工程量
/// </summary>
public class Quantity
{
[JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)]
public string Code { get; set; } [JsonProperty("desc", NullValueHandling = NullValueHandling.Ignore)]
public string Desc { get; set; } [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; } [JsonProperty("qty", NullValueHandling = NullValueHandling.Ignore)]
public string Qty { get; set; } [JsonProperty("unit", NullValueHandling = NullValueHandling.Ignore)]
public string Unit { get; set; }
}
系列目录 【已更新最新开发文章,点击查看详细】