Ejemplo n.º 1
0
        /// <summary>
        /// 给族添加comtype信息
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="type"></param>
        /// <param name="isCheck">对添加是否成功的检查的标志位,默认不检查,并返回true</param>
        /// <returns></returns>
        public static bool WriteParm(this Element fi, PmComTypeEnum type, bool isCheck = false)
        {
            if (fi == null || !fi.IsValidObject)
            {
                return(false);
            }

            MepDevParm parm = new MepDevParm()
            {
                comtype = 0
            };

            parm.comtype = (int)type;
            parm.WriteTo(fi);

            if (isCheck)
            {
                MepDevParm checkParm = new MepDevParm()
                {
                    comtype = 0
                };
                checkParm.ReadFrom(fi);
                return(checkParm.comtype == (int)type ? true : false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 为该管件相连的管件添加comtype信息
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="type"></param>
        public static void WriteParm_ConnectedFitting(this FamilyInstance fi, PmComTypeEnum type)
        {
            if (fi == null || !fi.IsValidObject || fi.MEPModel == null || fi.MEPModel.ConnectorManager == null)
            {
                return;
            }

            foreach (Connector con in fi.MEPModel.ConnectorManager.Connectors)
            {
                var linkedCon = con.GetConnectedConnector();
                if (linkedCon != null && linkedCon.Owner is FamilyInstance &&
                    (linkedCon.Owner.Category.Id.IntegerValue == (int)BuiltInCategory.OST_PipeFitting || linkedCon.Owner.Category.Id.IntegerValue == (int)BuiltInCategory.OST_DuctFitting || linkedCon.Owner.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CableTrayFitting || linkedCon.Owner.Category.Id.IntegerValue == (int)BuiltInCategory.OST_ConduitFitting))
                {
                    var linkedFi = linkedCon.Owner as FamilyInstance;
                    linkedFi.WriteParm(type, false);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取某标高下属于某comType信息的ElementId集合
        /// </summary>
        /// <param name="levelId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public virtual List <ElementId> GetElementIdByTypeOnLevel(ElementId levelId, PmComTypeEnum type)
        {
            List <ElementId> elementIds = new List <ElementId>();
            var elements = new FilteredElementCollector(this.m_RevitDoc).OfClass(typeof(FamilyInstance)).ToElements();

            foreach (var element in elements)
            {
                ElementId levelEmentId = element.GetParameters("标高").First().AsElementId();
                if (levelEmentId == levelId)
                {
                    bool isTypeOK = element.CheckTypeParam((int)type);
                    if (!isTypeOK)
                    {
                        continue;
                    }
                    elementIds.Add(element.Id);
                }
            }

            return(elementIds);
        }