Exemplo n.º 1
0
        /// <summary>
        /// 构造射线法查找对象
        /// </summary>
        /// <param name="view3D">三维视图很关键,交给上层去过滤</param>
        /// <param name="isFindInLinks">是否要查找连接文件</param>
        /// <param name="findReferenceTarget">需要查找的类型,可以是 Element Face Curve Edge Mesh 和 All </param>
        /// <param name="targetElementIds">目标元素的ElementId集合,如果你要查找链接文件中的元素,这个集合必须是RevitLinkInstance的Id,换句话说,集合中的元素Id不许都是当前文件中的Id</param>
        /// <param name="elementFilter">目标元素的过滤器</param>
        /// <returns></returns>
        /// <remarks>注意,view3D的视图可见性和裁剪框会影响结果</remarks>
        public static ReferenceIntersector GetReferenceIntersector(View3D view3D, bool isFindInLinks, FindReferenceTarget findReferenceTarget, ICollection <ElementId> targetElementIds = null, ElementFilter elementFilter = null)
        {
            if (view3D == null)
            {
                return(null);
            }

            ReferenceIntersector referenceIntersector = new ReferenceIntersector(view3D)
            {
                FindReferencesInRevitLinks = isFindInLinks,
                TargetType = findReferenceTarget
            };

            if (targetElementIds != null && targetElementIds.Count > 0)
            {
                referenceIntersector.SetTargetElementIds(targetElementIds);
            }
            if (elementFilter != null)
            {
                referenceIntersector.SetFilter(elementFilter);
            }

            return(referenceIntersector);
        }