首页 > 其他 > 详细

Revit 中的Selection

时间:2014-03-03 23:42:25      阅读:819      评论:0      收藏:0      [点我收藏+]

这篇随笔呢就对Revit开发中的Selection做一个总结吧。Selection顾名思义就是“选中”的意思。

You can get the selected objects from the current active document using the
UIDocument.Selection.Elements property. The selected objects are in an ElementSet in Revit. From
this Element set, all selected Elements are retrieved. The Selection object can also be used to
change the current selection programmatically.

The Selection class also has methods for allowing the user to select new objects, or even a point on
screen. This allows the user to select one or more Elements (or other objects, such as an edge or
a face) using the cursor and then returns control to your application. These functions do not
automatically add the new selection to the active selection collection.

在当前视图中选中对象的方式有四种:

1.The PickObject() method prompts the user to select an object in the Revit model. //选中一个对象

2.The PickObjects() method prompts the user to select multiple objects in the Revit model. //选中多个对象

3.The PickElementsByRectangle() method prompts the user to select multiple elements using a rectangle. //框选多个对象

4.The PickPoint() method prompts the user to pick a point in the active sketch plane.//选中一个点

下面是一个代码示例:

bubuko.com,布布扣
public static IList<Element> GetManyRefByRectangle(UIDocument doc)
{
    ReferenceArray ra = new ReferenceArray();
    ISelectionFilter selFilter = new MassSelectionFilter();//过滤类,项目中经常把需要过滤的条件封装成一个类
    IList<Element> eList = doc.Selection.PickElementsByRectangle(selFilter, 
    "Select multiple faces") as IList<Element>;
    return eList;
}
///
//分装的过滤类
///
public class MassSelectionFilter : ISelectionFilter { public bool AllowElement(Element element) { if (element.Category.Name == "Mass")//过滤的条件 { return true; } return false; } public bool AllowReference(Reference refer, XYZ point) { return false; } }
bubuko.com,布布扣

Revit 中的Selection,布布扣,bubuko.com

Revit 中的Selection

原文:http://www.cnblogs.com/love-huihui-zhupo/p/3578228.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!