示例#1
0
        //   面层对象的选择
        /// <summary>
        ///  从整个文档中的指定集合中搜索面层对象
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="elementIds"> 如果其值为null,则表示搜索集合为整个文档中的所有单元 </param>
        /// <returns></returns>
        private IList <WallFace> faceLookup(Document doc, ICollection <ElementId> elementIds)
        {
            List <WallFace> faces = new List <WallFace>();

            FilteredElementCollector coll;

            coll = (elementIds == null) ? new FilteredElementCollector(doc) : new FilteredElementCollector(doc, elementIds);

            // 首先判断类型
            coll.OfClass(typeof(DirectShape));

            // 判断单元的类别是否是指定的类别集合中的一个
            List <Element> faceCategoryElems = coll.Where(ele => CategoryIds.Contains(ele.Category.Id)).ToList();

            // 再判断参数中是否有标识参数
            Parameter pa;
            string    tag;

            foreach (Element ele in faceCategoryElems)
            {
                WallFace wf;
                if (!WallFace.IsWallFace(ele, out wf))
                {
                    continue;
                }
                // 满足所有过滤条件
                faces.Add(wf);
            }
            return(faces);
        }
示例#2
0
        /// <summary>
        /// 获取面层对象的标识符。正常情况下,此参数的值应该是一个常数“CMIE_面层”
        /// </summary>
        /// <param name="ds">  </param>
        /// <param name="wallFace"> 如果此函数返回 true,返回面层对象,如果此函数返回False,则此参数返回 null </param>
        /// <returns>如果没有找到此参数,则返回false。</returns>
        public static bool IsWallFace(DirectShape ds, out WallFace wallFace)
        {
            if (ds == null)
            {
                wallFace = null;
                return(false);
            }
            Parameter pa = ds.get_Parameter(FaceWallParameters.sp_FaceIdTag_guid);

            if (pa == null)
            {
                wallFace = null;
                return(false);
            }

            string idTag = pa.AsString();

            if (idTag == null || !pa.AsString().Equals(FaceWallParameters.FaceIdentificaion))
            {
                wallFace = null;
                return(false);
            }
            wallFace = new WallFace(ds);
            return(true);
        }
示例#3
0
        /// <summary>
        /// 获取面层对象的标识符。正常情况下,此参数的值应该是一个常数“CMIE_面层”
        /// </summary>
        /// <param name="ds">  </param>
        /// <param name="wallFace"> 如果此函数返回 true,返回面层对象,如果此函数返回False,则此参数返回 null </param>
        /// <returns>如果没有找到此参数,则返回false。</returns>
        public static bool IsWallFace(Element ds, out WallFace wallFace)
        {
            if (!(ds is DirectShape))
            {
                wallFace = null;
                return(false);
            }

            return(IsWallFace((DirectShape)ds, out wallFace));
        }
示例#4
0
        public bool AllowElement(Element element)
        {
            _elem = element;

            //
            if (_excludeFaceElement)  // 不选择面层对象
            {
                WallFace wf;
                if (WallFace.IsWallFace(element, out wf))
                {
                    return(false);
                }
                return(true);
            }
            return(true);
        }
示例#5
0
        //   根据指定的类别与类型来进行面层对象的过滤
        /// <summary>
        ///  从整个文档中的指定集合中 按指定的过滤选项 搜索面层对象
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="elementIds"> 如果其值为null,则表示过滤集合为整个文档中的所有单元 </param>
        /// <returns></returns>
        private IList <ElementId> Filterfaces(Document doc, ICollection <ElementId> elementIds, FaceOptions opt)
        {
            List <ElementId> faces = new List <ElementId>();

            FilteredElementCollector coll;

            coll = (elementIds == null) ? new FilteredElementCollector(doc) : new FilteredElementCollector(doc, elementIds);

            // 首先判断类型 与 过滤指定的类别
            coll.OfClass(typeof(DirectShape)).OfCategoryId(opt.CategoryId);

            // 跟据参数值进行过滤
            string tag;

            foreach (Element ele in coll)
            {
                WallFace wallface;

                if (!WallFace.IsWallFace(ele as DirectShape, out wallface))
                {
                    continue;
                }

                // 2. 过滤面层类型,如“防水”
                bool hasType = wallface.GetFaceType(out tag);
                if (!hasType || tag == null || !tag.Equals(opt.FaceType, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                // 满足所有过滤条件
                faces.Add(ele.Id);
            }

            return(faces);
        }