一个三维模型中可能包含对应多张二维图纸列表,如果在在上传转换时设置导出二维图纸,则转换完成后三维模型自动关联所有的二维图纸。

在BIM查看器的左上角【视图】->【目录树】下拉选项中选择“图纸”选项,如果三维模型包含二维图纸,则在上传转换时设置导出二维图纸,则此处就会列出所有的图纸。双击一个图纸,右上侧显示该图纸。当双击三维模型的构件时,如果包含对应的二维图纸,则自动定位到二维图纸上;双击二维图纸上的图元时,自动定位到三维模型的构件。

本篇主要介绍如何获取模型文件对应的图纸列表。

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

说明:获取单个模型文件对应的图纸列表。如果请求参数elementId为null,返回所有图纸,否则返回包含该构件的所有图纸。

参数:

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

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

HTTP响应示例(200):

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

返回结果的结构比较复杂。封装成对应的 C# 类,SingleModelDrawingSheets

/// <summary>
/// 获取单个模型的图纸列表返回的结果类
/// </summary>
[Serializable]
public class SingleModelDrawingSheets : GeneralResponse<List<DrawingSheet>>
{ }

引用的 DrawingSheet 类

/// <summary>
/// 图纸信息类
/// </summary>
[Serializable]
public class DrawingSheet
{
/// <summary>
/// 文件ID
/// </summary>
[JsonProperty("fileId")]
public long? FileId { get; set; } /// <summary>
/// 样例 : [ 0.0 ]
/// </summary>
[JsonProperty("portsAndViews")]
public PortAndView[] PortAndViews { get; set; } [JsonProperty("viewInfo")]
public ViewInfo ViewInfo { get; set; } /// <summary>返回表示当前对象的字符串。</summary>
/// <returns>表示当前对象的字符串。</returns>
public override string ToString()
{
return String.Format("[fileId={0}, portAndViews={1}, viewInfo={2}]",
FileId, PortAndViews.ToStringLine(), ViewInfo);
}
}

引用的 PortAndView 类

[Serializable]
public class PortAndView
{
/// <summary>
/// 样例 : 0.0
/// </summary>
[JsonProperty("elevation")]
public double? Elevation { get; set; } /// <summary>
/// 样例 : [ 0.0 ]
/// </summary>
[JsonProperty("outline")]
public double?[] Outline { get; set; } /// <summary>
/// 样例 : "6278f2c7786043d4a35ae4115571b7c8"
/// </summary>
[JsonProperty("viewId")]
public string ViewId { get; set; } [JsonProperty("viewPoint")]
public ViewPoint ViewPoint { get; set; } /// <summary>
/// 样例 : "viewType"
/// </summary>
[JsonProperty("viewType")]
public string ViewType { get; set; } /// <summary>
/// 样例 : [ 0.0 ]
/// </summary>
[JsonProperty("viewport")]
public double?[] Viewport { get; set; } /// <summary>返回表示当前对象的字符串。</summary>
/// <returns>表示当前对象的字符串。</returns>
public override string ToString()
{
return String.Format("[elevation={0}, outline={1}, viewId={2}, viewPoint={3}, viewType={4}, viewport={5}]",
Elevation, Outline.ToStringWith(","), ViewId, ViewPoint, ViewType, Viewport.ToStringWith(","));
}
}

引用的 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>
/// 获取单个模型的图纸列表。
/// 如果请求参数elementId为null,返回所有图纸,否则返回包含该构件的所有图纸
/// </summary>
/// <param name="accessToken">【必填】令牌</param>
/// <param name="fileId">【必填】代表该单模型的文件ID</param>
/// <param name="elementId">【非必填】构件ID</param>
/// <returns></returns>
public virtual SingleModelDrawingSheets GetSingleModelDrawingSheets(string accessToken, long fileId, string elementId = null)
{
// GET https://api.bimface.com/data/v2/files/{fileId}/drawingsheets
string url = string.Format(BimfaceConstants.API_HOST + "/data/v2/files/{0}/drawingsheets", fileId);
if (!string.IsNullOrWhiteSpace(elementId))
{
url = url + "?elementId=" + elementId;
} BimFaceHttpHeaders headers = new BimFaceHttpHeaders();
headers.AddOAuth2Header(accessToken); try
{
SingleModelDrawingSheets response; HttpManager httpManager = new HttpManager(headers);
HttpResult httpResult = httpManager.Get(url);
if (httpResult.Status == HttpResult.STATUS_SUCCESS)
{
response = httpResult.Text.DeserializeJsonToObject<SingleModelDrawingSheets>();
}
else
{
response = new SingleModelDrawingSheets
{
Message = httpResult.RefText
};
} return response;
}
catch (Exception ex)
{
throw new Exception("[获取图纸列表]发生异常!", ex);
}
}
测试

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

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

完整的图纸列表信息为:

success

[fileId=,
portAndViews=,
viewInfo=[cropBox=-30479.998046875,-30479.998046875,-,30479.998046875,30479.998046875,-30.4799995422363,
elevation=,
width=,
Id=,
levelId=,
Outline=2.49999989974552,-0.999999959964061,842.499966258321,592.999976250742,
preview=[height=,
path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails//.png,
width=
],
thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails//.96x96.png,
viewPoint=[height=, path=, width=],
viewType=DrawingSheet]
] [fileId=,
portAndViews=,
viewInfo=[cropBox=-30479.998046875,-30479.998046875,-,30479.998046875,30479.998046875,-30.4799995422363,
elevation=,
width=,
Id=,
levelId=,
Outline=2.49999989974552,-0.999999959964061,842.499966258321,592.999976250742,
preview=[height=,
path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails//.png,
width=
],
thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails//.96x96.png,
viewPoint=[height=, path=, width=],
viewType=DrawingSheet
]
] [fileId=,
portAndViews=,
viewInfo=[cropBox=-30479.998046875,-30479.998046875,-,30479.998046875,30479.998046875,-30.4799995422363,
elevation=,
width=,
Id=,
levelId=,
Outline=2.49999989974552,-0.999999959964061,842.499966258321,592.999976250742,
preview=[height=,
path=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails//.png,
width=
],
thumbnails=m.bimface.com/6bd2057ac6d8072ad03758b0b34e205d/resource/thumbnails//.96x96.png,
viewPoint=[height=, path=, width=],
viewType=DrawingSheet
]
]

测试代码如下:

// 获取图纸列表
protected void btnGetSingleModelDrawingSheets_Click(object sender, EventArgs e)
{
long fileId = txtFileID.Text.Trim().ToLong();
string elementId = txtElementId.Text.Trim();
FileConvertApi api = new FileConvertApi();
SingleModelDrawingSheets response = api.GetSingleModelDrawingSheets(txtAccessToken.Text, fileId, elementId); txtResult.Text = response.Code.ToString2()
+ Environment.NewLine
+ response.Message.ToString2()
+ Environment.NewLine
+ response.Data.ToStringLine();
}

我的博客即将同步至腾讯云+社区,邀请大家一同入驻:

https://cloud.tencent.com/developer/support-plan?invite_code=1e6h2qd3iny51

 

最新文章

  1. android中导入低版本project可能会遇到的编译问题(转自: Victor@Beijing)
  2. CentOS7 编译安装 Nodejs (实测 笔记 Centos 7.0 + node 0.10.33)
  3. Windows Directory ACL Security Check By ACL Baseline
  4. 使用Eclipse调试PHP程序
  5. xss跨站实例总结
  6. Android 仿美团网,大众点评购买框悬浮效果之修改版
  7. Linux内核基础--事件通知链(notifier chain)
  8. MySQL Timeout解析
  9. webservice简单总结
  10. SQL2008R2日志传送需要注意点
  11. 用74HC165读8个按键状态(转)
  12. org.hibernate.TransientObjectException:The given object has a null identifier
  13. NTP服务器搭建
  14. thinkphp5 图片下载保存
  15. selenium java 浏览器操作
  16. Can not issue data manipulation statements with executeQuery()错误解决
  17. 利用微信企业号的告警功能,联动检测ICMP的shell脚本
  18. Hadoop学习笔记03_Hive练习
  19. jdbc java远程连接mysql数据库服务器
  20. Spring学习之路-从放弃到入门

热门文章

  1. CentOS 安装Asp.net Core &amp; FTP服务
  2. Mysql基本注入
  3. 高阶组件&amp;&amp;高阶函数(一)
  4. IT兄弟连 HTML5教程 HTML5表单 HTML5新增表单元素
  5. 【linux命令】chgrp改变文件或目录的属组
  6. Ruby入门1
  7. 【朝花夕拾】Android自定义View篇之(四)自定义View的三种实现方式及自定义属性使用介绍
  8. CronExpression表达式详解和案例
  9. 代码审计 =&gt; 74cms_v3.5.1.20141128 一系列漏洞
  10. 服务器返回的数据将Unicode码转成汉字