Categories
Uncategorized

C # developers BIMFACE Series server 18 acquires the model data 3 API: acquiring attribute member

系列目录     【已更新最新开发文章,点击查看详细】

This part describes how to obtain the attribute information in single file / model single construct.

Address Request: GET https://api.bimface.com/data/v2/files/{fileId}/elements/{elementId}

Description: Support attribute property overrides the query model components need to be set to the value true request parameters includeOverrides

parameter:

Request path (Example): https: //api.bimface.com/data/v2/files/1211223382064960/elements/1109329

For the rewritten query attribute member, exemplified request

                            https://api.bimface.com/data/v2/files/1211223382064960/elements/1109329?includeOverrides=true

Request header (Example): “Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b”

Example HTTP response (200):

{
  "code" : "success",
  "data" : {
    "boundingBox" : {
      "max" : {
        "x" : -4938.068482562385,
        "y" : -3201.59397858169,
        "z" : 0.0
      },
      "min" : {
        "x" : -4938.068482562385,
        "y" : -3201.59397858169,
        "z" : 0.0
      }
    },
    "elementId" : "313052",
    "familyGuid" : "000222",
    "guid" : "79d547c1-5dbf-4e6a-811d-951cf37b29da-0004c6dc",
    "name" : "norm - 150mm",
    "properties" : [ {
      "group" : "dimension",
      "items" : [ {
        "code" : "perimeter",
        "extension" : "object",
        "key" : "perimeter",
        "orderNumber" : 0,
        "unit" : "mm",
        "value" : 17200,
        "valueType" : 2
      } ]
    } ]
  },
  "message" : ""
}

C # implementation:

 1 /// 
 2 ///  获取构件属性
 3 /// 
 4 /// 

Token

5 ///

[Required] on behalf of the single model file ID

6 ///

[Required] the representative member ID of the single-model

7 ///

[Optional] query whether the modified property

8 /// 9 public virtual SingleModelSingleElementProperty GetSingleModelSingleElementProperty(string accessToken, long fileId, string elementId, bool? includeOverrides = null) 10 { 11 // GET https://api.bimface.com/data/v2/files/{fileId}/elements/{elementId} 12 string url = string.Format(BimfaceConstants.API_HOST + "/data/v2/files/{0}/elements/{1}", fileId, elementId); 13 if (includeOverrides != null) 14 { 15 url = url + "?includeOverrides=" + includeOverrides; 16 } 17 18 BimFaceHttpHeaders headers = new BimFaceHttpHeaders(); 19 headers.AddOAuth2Header(accessToken); 20 21 try 22 { 23 SingleModelSingleElementProperty response; 24 25 HttpManager httpManager = new HttpManager(headers); 26 HttpResult httpResult = httpManager.Get(url); 27 if (httpResult.Status == HttpResult.STATUS_SUCCESS) 28 { 29 response = httpResult.Text.DeserializeJsonToObject(); 30 } 31 else 32 { 33 response = new SingleModelSingleElementProperty 34 { 35 Message = httpResult.RefText 36 }; 37 } 38 39 return response; 40 } 41 catch (Exception ex) 42 { 43 throw new Exception("

[Get component property] abnormal!

", ex); 44 } 45 }

Which calls to httpManager.Get () method, please refer to “C # HTTP Series”

Responsive results corresponding entity class SingleModelSingleElementProperty, the package is as follows:

/// 
/// 获取单个模型单个构件的属性返回的结果类
/// 
[Serializable]
public class SingleModelSingleElementProperty : GeneralResponse
{

}
 1 [Serializable]
 2 public class SingleModelSingleElementEntity
 3 {
 4     [JsonProperty("boundingBox")]
 5     public BoundingBox BoundingBox { get; set; }
 6 
 7     [JsonProperty("elementId")]
 8     public string ElementId { get; set; }
 9 
10     [JsonProperty("familyGuid")]
11     public string FamilyGuid { get; set; }
12 
13     [JsonProperty("guid")]
14     public string Guid { get; set; }
15 
16     [JsonProperty("name")]
17     public string Name { get; set; }
18 
19     [JsonProperty("properties")]
20     public PropertyGroup[] Properties { get; set; }
21 
22     /// 

Returns the string that represents the current object.

23 ///

A string that represents the current object.

24 public override string ToString() 25 { 26 StringBuilder sb = new StringBuilder(); 27 if (Properties != null && Properties.Length > 0) 28 { 29 foreach (var pro in Properties) 30 { 31 sb.AppendLine(pro.ToString()); 32 } 33 } 34 35 return string.Format("SingleModelSingleElementEntity: [boundingBox={0}, elementId={1}, familyGuid={2}, Guid={3}, name={4}, Properties={5}]", 36 BoundingBox, ElementId, FamilyGuid, Guid,Name, sb); 37 } 38 }
 1 [Serializable]
 2 public class BoundingBox
 3 {
 4     [JsonProperty("max")]
 5     public Max Max { get; set; }
 6 
 7     [JsonProperty("min")]
 8     public Min Min { get; set; }
 9 
10     /// 

Returns the string that represents the current object.

11 ///

A string that represents the current object.

12 public override string ToString() 13 { 14 return string.Format("[max={0}, min={1}]", Max.ToString(), Min.ToString()); 15 } 16 }
1 [Serializable]
2 public class Max : ThreeDimensionalCoordinates
3 {
4 }
[Serializable]
public class Min : ThreeDimensionalCoordinates
{
}
/// 
///  三维坐标系
/// 
public class ThreeDimensionalCoordinates
{
    [JsonProperty("x")]
    public double X { get; set; }

    [JsonProperty("y")]
    public double Y { get; set; }

    [JsonProperty("z")]
    public double Z { get; set; }

    /// 

Returns the string that represents the current object.

///

A string that represents the current object.

public override string ToString() { return string.Format("[x={0}, y={1}, z={2}]", X, Y, Z); } }

Wherein PropertyGroup type, refer to “C # developers BIMFACE series API server 17 acquires the model data 2: Get a list of member material” response results PropertyGroup class class.

测试

In BIMFACE console can see a list of files we uploaded a total of 2 files. Model states are successful conversion.

To “01_BIMFACE sample files -Revit model .rvt” example to test.

 

Complete property:

success
elementId:300067

SingleModelSingleElementEntity: 
[boundingBox=[max=[x=5838.783, y=4387.716, z=6000], 
              min=[x=5788.783, y=4237.716, z=5475]
             ], 
 elementId=300067, 
 familyGuid=2d99307a-66cd-4439-b173-5c88d252416e-00002122, 
 Guid=89c90034-40ae-423a-8935-8f5624db86c1-00049423, 
 name=50 x 150 mm, 
 Properties=
    [group=基本属性, 
     items= [code=, extension=, key=specialty, orderNumber=,unit=,value=,valueType=]
            [code=, extension=, key=floor, orderNumber=,unit=,value=F2,valueType=]
            [code=, extension=, key=categoryId, orderNumber=,unit=,value=-2000171,valueType=]
            [code=, extension=, key=categoryName, orderNumber=,unit=,value=幕墙竖梃,valueType=]
            [code=, extension=, key=family, orderNumber=,unit=,value=矩形竖梃,valueType=]
            [code=, extension=, key=familyId, orderNumber=,unit=,value=,valueType=]
            [code=, extension=, key=familyType, orderNumber=,unit=,value=50 x 150 mm,valueType=]
            [code=, extension=, key=familyTypeId, orderNumber=,unit=,value=8486,valueType=]
            [code=, extension=, key=systemType, orderNumber=,unit=,value=,valueType=]
            [code=, extension=, key=building, orderNumber=,unit=,value=,valueType=]
    ]
    [group=尺寸标注, 
     items=[code=, extension=, key=边 1 上的宽度, orderNumber=,unit=mm,value=25,valueType=2]
           [code=, extension=, key=边 2 上的宽度, orderNumber=,unit=mm,value=25,valueType=2]
           [code=, extension=, key=长度, orderNumber=,unit=mm,value=525,valueType=2]
    ]
    [group=材质和装饰, 
     items=[code=, extension=, key=材质, orderNumber=,unit=,value=金属 - 铝,valueType=4]
    ]
    [group=构造, 
     items=[code=, extension=, key=位置, orderNumber=,unit=,value=垂直于面,valueType=4]
           [code=, extension=, key=厚度, orderNumber=,unit=mm,value=150,valueType=2]
           [code=, extension=, key=角竖梃, orderNumber=,unit=,value=False,valueType=1]
           [code=, extension=, key=轮廓, orderNumber=,unit=,value=默认,valueType=4]
    ]
    [group=标识数据, 
     items=[code=, extension=, key=OmniClass 标题, orderNumber=,unit=,value=,valueType=3]
           [code=, extension=, key=OmniClass 编号, orderNumber=,unit=,value=,valueType=3]
           [code=, extension=, key=URL, orderNumber=,unit=,value=,valueType=3]
           [code=, extension=, key=代码名称, orderNumber=,unit=,value=,valueType=3]
           [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=,valueType=2]
           [code=, extension=, key=标记, orderNumber=,unit=,value=,valueType=3]
           [code=, extension=, key=注释, orderNumber=,unit=,value=,valueType=3]
           [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=,valueType=3]
           [code=, extension=, key=说明, orderNumber=,unit=,value=,valueType=3]
           [code=, extension=, key=部件代码, orderNumber=,unit=,value=,valueType=3]
           [code=, extension=, key=部件说明, orderNumber=,unit=,value=,valueType=3]
    ]
    [group=阶段化, 
     items=[code=, extension=, key=创建的阶段, orderNumber=,unit=,value=新构造,valueType=4]
           [code=, extension=, key=拆除的阶段, orderNumber=,unit=,value=无,valueType=4]
    ]
    [group=限制条件, 
     items=[code=, extension=, key=偏移量, orderNumber=,unit=mm,value=0,valueType=2]
           [code=, extension=, key=角度, orderNumber=,unit=°,value=0.00,valueType=2]
    ]
]

Test code is as follows:

 1 //

Acquiring attribute member

2 protected void btnGetSingleModelSingleElementProperty_Click(object sender, EventArgs e) 3 { 4 FileConvertApi api = new FileConvertApi(); 5 6 string elementId = ddlSingleModelElements.SelectedValue; 7 8 SingleModelSingleElementProperty response = api.GetSingleModelSingleElementProperty(txtAccessToken.Text, txtFileID.Text.ToLong(), elementId, chkIncludeOverrides.Checked); 9 10 txtResult.Text = response.Code.ToString2() 11 + Environment.NewLine 12 + "elementId:" + elementId 13 + Environment.NewLine 14 + response.Message.ToString2() 15 + Environment.NewLine 16 + response.Data.ToString(); 17 }

系列目录     【已更新最新开发文章,点击查看详细】
 

Leave a Reply