Revit二次开发——从链接文件中选取指定元素

image_print阅读模式


这里稍微讲一下怎么从链接文件中选取指定元素,这里以选取Space为例。
首先要另写一个Class。

public class SelectionLinkFilter : ISelectionFilter
 {
 Document linkDoc = null;
 public bool AllowElement(Element elem)
 {
 if(elem is RevitLinkInstance)
 {
 linkDoc = (elem as RevitLinkInstance).GetLinkDocument();
 return true;
 }
 return false;
 }

 public bool AllowReference(Reference reference, XYZ position)
 {
 if(linkDoc.GetElement(reference.LinkedElementId) is Space)
 {
 return true;
 }
 return false;
 }
 }

然后在选择中用这个class;

 UIDocument uiDoc = commandData.Application.ActiveUIDocument;
 Reference reference = uiDoc.Selection.PickObject(ObjectType.LinkedElement, new SelectionLinkFilter());
0

评论0

请先
新22G07 预应力混凝土钢管桁架叠合板
新22G07 预应力混凝土钢管桁架叠合板
8分钟前 有人购买 去瞅瞅看
没有账号?注册  忘记密码?

社交账号快速登录

微信扫一扫关注
扫码关注后会自动登录网站