首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > windows >

Building Coder - UIView 跟 Windows 设备坐标

2012-10-14 
Building Coder - UIView 和 Windows 设备坐标原文链接:UIView and Windows Device CoordinatesRevit 2013

Building Coder - UIView 和 Windows 设备坐标
原文链接:UIView and Windows Device Coordinates

Revit 2013 API 中新提供了一个新的视图 API,具体地说是提供一个新类 UIView。UIView 代表一个视图窗口,让我们可以通过程序来移动、缩放和决定窗口平铺时的大小等等一系列操作。也为我们从其它可视化环境切换回视图提供了可能。


UIView 目前只公开了三个方法:
1. GetWindowRectangle:使用窗口坐标系返回视图的绘图区域的矩形坐标;
2. GetZoomCorners:使用 Revit 模型坐标系返回视图矩形的四个角坐标;
3. ZoomAndCreateRectangle:将视图缩放并居中到一个指定的矩形区域中

UIView 是 Revit API 第一次提供了窗口坐标和 Revit 坐标之间的关联,开启了 Revit 全新的交互方式。比方说:在 Idling 事件中显示自定义的 Tooltip ……

值得一提的是,目前 Revit API 只能通过 UIDocument.GetOpenUIViews() 方法获取 UIView 对象。由于每个 UIView 都是和一个视图绑定的,所以我们可以通过 UIView.ViewId 来判断某个 UIView 是属于哪个视图的。


我创建了一个简单的外部命令 WinCoords 来测试 UIView。它的功能如下:
- 获取当前视图
- 获取当前文档的所有 UIView 对象
- 找到属于当前视图的 UIView 对象
- 读取当前 UIView 的窗口和 Revit 坐标
- 调用 ZoomAndCenterRectangle 将 Revit 模型放大 10%

/// <summary>/// 返回一个表示矩形区域的字符串,格式是(左上角)-(右下角)/// 窗口坐标系的 Y 方向是相反方向/// </summary>static string RectangleString( Rectangle r ){return string.Format( "({0},{1})-({2},{3})", r.Left, r.Top, r.Right, r.Bottom );}


热点排行