您的位置:首页 > 其它

Revit开发在链接模型中使用ISelectionFilter

2016-09-19 17:06 309 查看
在链接模型中使用ISelectionFilter,

关键代码:

            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            Document doc = uidoc.Document;

            IList<Reference> refs = uidoc.Selection.PickObjects(ObjectType.LinkedElement, new LinkSelectionFilter());

            TaskDialog.Show("数量:", refs.Count().ToString());

    public class LinkSelectionFilter : ISelectionFilter

    {

        RevitLinkInstance rvtIns = null;

        public bool AllowElement(Element elem)

        {

            if (elem is RevitLinkInstance)

            {

                rvtIns = elem as RevitLinkInstance;

                return true;

            }

            return false;

        }

        public bool AllowReference(Reference reference, XYZ position)

        {

            Document doc = rvtIns.GetLinkDocument();

            Element elm = doc.GetElement(reference.LinkedElementId);

            if (elm is Pipe)

                return true;

            return false;

        }

    }

博主会经常更新一些技术文章,请大家多多关注,

源码下载请加qq群480950299
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: