更新
This commit is contained in:
135
Revit-API/UIDocument.md
Normal file
135
Revit-API/UIDocument.md
Normal file
@@ -0,0 +1,135 @@
|
||||
# UIDocument
|
||||
|
||||
## 方法
|
||||
|
||||
### CanPlaceElementType
|
||||
|
||||
当前视图是否可以放置该类型构件
|
||||
| 方法名 | 描述 |
|
||||
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| | |
|
||||
| GetOpenUIViews | 获取 Revit 用户界面中所有打开的视图窗口的列表。 |
|
||||
| GetPlacementTypes | 获取输入族类型的有效放置类型的集合。 |
|
||||
| GetRevitUIFamilyLoadOptions | 返回选项对象,允许您使用 Revit 的对话框让用户响应在加载族期间出现的问题。 |
|
||||
| PostRequestForElementTypePlacement | 在Revit的命令队列中放置一个请求,让用户放置指定ElementType的实例。这不会立即执行,而是在控制权从当前API上下文返回到Revit时执行。 |
|
||||
|| |
|
||||
|
||||
### GetOpenUIViews
|
||||
|
||||
获取 Revit 用户界面中所有打开的视图窗口的列表。
|
||||
|
||||
```
|
||||
UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||||
Document doc = uidoc.Document;
|
||||
IList<UIView> views = uidoc.GetOpenUIViews();
|
||||
foreach (UIView view in views)
|
||||
{
|
||||
if (view.ViewId != uidoc.ActiveView.Id) continue;
|
||||
view.ZoomToFit();
|
||||
}
|
||||
|
||||
- close()
|
||||
|
||||
关闭窗口
|
||||
|
||||
- GetWindowRectangle()
|
||||
|
||||
获得窗口的Rectangle
|
||||
|
||||
Rectangle
|
||||
|
||||
- GetZoomCorners()
|
||||
|
||||
获得窗口四个角的点
|
||||
|
||||
- ViewId
|
||||
|
||||
所属View的ID
|
||||
|
||||
- Zoom(double d)
|
||||
|
||||
变焦
|
||||
|
||||
- ZoomAndCenterRectangle(XYZ 1,XYZ 2)
|
||||
|
||||
根据提供的Rectangle变焦
|
||||
|
||||
- ZoomToFit()
|
||||
|
||||
变焦至显示所有构件(缩放匹配)
|
||||
|
||||
- ZoomSheetSize()
|
||||
|
||||
变焦至Sheet的大小
|
||||
```
|
||||
|
||||
### GetPlacementTypes
|
||||
|
||||
获取输入族类型的有效放置类型的集合。
|
||||
|
||||
### PostRequestForElementTypePlacement(ElementType type)
|
||||
|
||||
在Revit的命令队列中放置一个请求,让用户放置指定ElementType的实例。这不会立即执行,而是在控制权从当前API上下文返回到Revit时执行。
|
||||
|
||||
```
|
||||
UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||||
Document doc = uidoc.Document;
|
||||
// id为ElementType 的ID,可根据自己的项目文件修改
|
||||
int id = 266107;
|
||||
uidoc.PostRequestForElementTypePlacement(doc.GetElement(new ElementId(id)) as ElementType);
|
||||
```
|
||||
|
||||
### GetRevitUIFamilyLoadOptions
|
||||
|
||||
返回选项对象,允许您使用 Revit 的对话框让用户响应在加载族期间出现的问题。
|
||||
|
||||
### RefreshActiveView()
|
||||
|
||||
- 刷新当前视图
|
||||
|
||||
### RequestViewChange(View view)
|
||||
|
||||
- 改变当前视图
|
||||
可用ActiveView
|
||||
|
||||
UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||||
Document doc = uidoc.Document;
|
||||
// id 为视图的Id,需要根据自己项目更改;
|
||||
int id = 3728299;
|
||||
View view = doc.GetElement(new ElementId(id)) as View;
|
||||
uidoc.RequestViewChange(view);
|
||||
|
||||
### SaveAndClose()
|
||||
|
||||
- 保存关闭
|
||||
|
||||
### SaveAs()
|
||||
|
||||
## 属性
|
||||
|
||||
### [[Selection]]
|
||||
|
||||
获得Selection对象
|
||||
|
||||
```
|
||||
UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||||
Document doc = uidoc.Document;
|
||||
Selection sel = uidoc.Selection;
|
||||
Reference r = sel.PickObject(ObjectType.Element);
|
||||
Element element = doc.GetElement(r);
|
||||
TaskDialog.Show("AS", element.Name);
|
||||
```
|
||||
|
||||
### ActiveView
|
||||
|
||||
- UIDocument uidoc = commandData.Application.ActiveUIDocument;
|
||||
Document doc = uidoc.Document;
|
||||
// id 为视图的Id,需要根据自己项目更改;
|
||||
int id = 3728299;
|
||||
View view = doc.GetElement(new ElementId(id)) as View;
|
||||
uidoc.ActiveView = view;
|
||||
|
||||
ViewDirection是视图朝向观察者的方向,UpDirection视图向上的方向
|
||||
UpDirection x ViewDirection=RightDirection
|
||||
ViewDirection x RightDirection=UpDirection
|
||||
RightDirection xUpDirection=ViewDirection
|
||||
Reference in New Issue
Block a user