void EncodeEquipment()
        {
            ElementClassFilter       instanceFilter = new ElementClassFilter(typeof(FamilyInstance));
            ElementClassFilter       hostFilter     = new ElementClassFilter(typeof(HostObject));
            LogicalOrFilter          andFilter      = new LogicalOrFilter(instanceFilter, hostFilter);
            FilteredElementCollector collector      = new FilteredElementCollector(m_uIDocument.Document);

            collector.WherePasses(andFilter);

            foreach (var ele in collector)
            {
                var catogary   = ele.Category.Name;
                var familyName = MtCommon.GetElementFamilyName(m_uIDocument.Document, ele);
                if (familyName.Contains("风盘") || familyName.Contains("风机盘管"))
                {
                    continue;
                }
                if (catogary.Equals(MtGlobals.EquipmentCategory) || catogary.Equals(MtGlobals.ElecticCategory))
                {
                    //temp
                    var length = familyName.Length;
                    MtCommon.SetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.EquipmentCode),
                                             length <= 5 ? familyName.Substring(0, length - 1) : familyName.Substring(0, 5));
                }
            }
        }
        public void CheckPipeBasicInfo()
        {
            ElementClassFilter instanceFilter = new ElementClassFilter(typeof(FamilyInstance));
            ElementClassFilter hostFilter     = new ElementClassFilter(typeof(HostObject));
            LogicalOrFilter    andFilter      = new LogicalOrFilter(instanceFilter, hostFilter);

            FilteredElementCollector collector = new FilteredElementCollector(m_uIDocument.Document);

            collector.WherePasses(andFilter);

            foreach (var ele in collector)
            {
                CheckPipeParameters(ele);//是否有基础信息

                string category = ele.Category.Name;
                if (category.Equals(MtGlobals.PipeCategory) || category.Equals(MtGlobals.DustCategory))
                {
                    GetParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.VerticalPipe)); //检测竖管是否有参数
                }
                else if (category.Equals(MtGlobals.EquipmentCategory))
                {
                    if (ele.Name.Contains("风盘") || ele.Name.Contains("风机盘管"))
                    {
                        continue;
                    }
                    GetParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.EquipmentCode)); //设备是否有编码
                }
            }
            //MtCommon.IsolateElements(m_uIDocument.Document, m_ltBasicInfoErrors.Select(k => k.Key).ToList());
        }
 private void CheckPipeParameters(Element ele)
 {
     GetParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Campus));
     GetParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Building));
     GetParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.MtLevel));
     GetParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.SubDistrict));
 }
        private void SystemComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selSysName = SystemComboBox.SelectedItem.ToString();

            MtGlobals.SystemName selectSys = MtCommon.GetEnumValueByString <MtGlobals.SystemName>(selSysName);

            switch (selectSys)
            {
            case MtGlobals.SystemName.AC:
                m_ltCurSystemNames          = CreateCheckBox(MtCommon.GetEnumAttributeNames(typeof(MtGlobals.ACSubSystem)));
                StandardSysList.ItemsSource = m_ltCurSystemNames;
                break;

            case MtGlobals.SystemName.WSAD:
                m_ltCurSystemNames          = CreateCheckBox(MtCommon.GetEnumAttributeNames(typeof(MtGlobals.WSADSubSystem)));
                StandardSysList.ItemsSource = m_ltCurSystemNames;
                break;

            case MtGlobals.SystemName.MG:
                m_ltCurSystemNames          = CreateCheckBox(MtCommon.GetEnumAttributeNames(typeof(MtGlobals.MGSubSystem)));
                StandardSysList.ItemsSource = m_ltCurSystemNames;
                break;

            case MtGlobals.SystemName.Steam:
                m_ltCurSystemNames          = CreateCheckBox(MtCommon.GetEnumAttributeNames(typeof(MtGlobals.SteamSubSystem)));
                StandardSysList.ItemsSource = m_ltCurSystemNames;
                break;

            default:
                break;
            }
        }
        private void InitPipeRelation()
        {
            if (m_pipeRelation == null)
            {
                return;
            }
            SubSystemNameComBox.ItemsSource = MtCommon.GetEnumAttributeNames(typeof(MtGlobals.EPSystem));
            m_pipeRelation.SystemName       = SystemNameComBox.Text;
            m_pipeRelation.SubSystemName    = SubSystemNameComBox.Text;

            Tunnel.ItemsSource        = MtCommon.GetEnumAttributeNames(typeof(MtGlobals.Tunnel));
            m_pipeRelation.TunnelName = Tunnel.Text;

            if (null != db_path.Text)
            {
                m_pipeRelation.DBFilePath = db_path.Text;
            }
            if (null != TableName.Text)
            {
                m_pipeRelation.TableName = TableName.Text;
            }
            if (null != ColumnName.Text)
            {
                m_pipeRelation.ColumnName = ColumnName.Text;
            }
            if (MultiSystem != null && null != MultiSystem.Text)
            {
                m_pipeRelation.MultiSystem = MultiSystem.Text;
            }

            m_pipeRelation.IsPositiveDir      = IsPositiveDir.IsChecked == true ? true : false;
            m_pipeRelation.IsWaterReturnPipe  = IsWaterReturn.IsChecked == true ? true : false;
            m_pipeRelation.IsSameSystem       = SameSystemCheck.IsChecked == true ? true : false;
            m_pipeRelation.IsIsolatedElements = IsIsolatedElemtns.IsChecked == true ? true : false;
        }
Example #6
0
        public void TestMultiStartPipe()
        {
            GetElementSystem();
            if (m_startElements.Count == 0)
            {
                return;
            }
            List <Element> totalSelectElements = new List <Element>();
            var            index = 0;

            foreach (var item in m_startElements)
            {
                TestLoopCircuit(item, (eles) => {
                    totalSelectElements = totalSelectElements.Union(eles).ToList();
                    ++index;
                    if (index == m_startElements.Count)
                    {
                        if (m_isIsolatedElments)
                        {
                            MtCommon.IsolateElements(m_uIDocument.Document, totalSelectElements);
                        }
                        else
                        {
                            MtCommon.HideElements(m_uIDocument.Document, totalSelectElements);
                        }
                    }
                });
            }
        }
        //分区
        private void SetSubRegionParameter(Element ele)
        {
            if (null == ele)
            {
                return;
            }

            Parameter param = ele.LookupParameter(MtCommon.GetStringValue(MtGlobals.Parameters.SubDistrict));

            if (null != param)
            {
                if (string.IsNullOrEmpty(param.AsString()))
                {
                    bool successed = param.Set("A");
                    if (!successed)
                    {
                        string errorType = MtCommon.GetStringValue(ErrorType.SetParamterFailed) + MtCommon.GetStringValue(MtGlobals.Parameters.SubDistrict);
                        AddListViewErrorData(ele, errorType);
                    }
                }
            }
            else
            {
                string errorType = MtCommon.GetStringValue(ErrorType.NoParameter) + MtCommon.GetStringValue(MtGlobals.Parameters.SubDistrict);
                AddListViewErrorData(ele, errorType);
            }
        }
        List <Element> GetConnectElements(Element ele)
        {
            List <Element> list = new List <Element>();

            try {
                ConnectorSet connectorSet = MtCommon.GetAllConnectors(ele);

                if (connectorSet != null && connectorSet.Size != 0)
                {
                    foreach (Connector item in connectorSet)
                    {
                        if (item.Domain != Domain.DomainElectrical)
                        {
                            Connector connector = MtCommon.GetConnectedConnector(item);

                            if (connector != null)
                            {
                                Element element = connector.Owner;
                                list.Add(element);
                            }
                        }
                    }
                }
                else
                {
                    //模型自身没有连接点
                    AddListViewErrorData(ele, "模型自身没有连接点");
                }
            } catch (Exception e) {
                throw new Exception(e.Message);
            }
            return(list);
        }
 private void SetParameters(Element ele, bool isPipe = false, bool isEnVersion = false)
 {
     m_isEnVersion = MtCommon.IsEnglishVersion(m_uiApp);
     SetDistrictParameter(ele, m_district);
     SetBuildingParameter(ele, m_building);
     SetSubRegionParameter(ele);
     SetLevelParameter(ele, isPipe, isEnVersion);
 }
        private void SetLevelParameter(Element ele, bool isPipe = false, bool isEnVersion = false)
        {
            if (ele == null)
            {
                return;
            }
            string level = string.Empty;

            if (isEnVersion)
            {
                if (isPipe)
                {
                    level = GetPipeLevelParamEN(ele);
                }
                else
                {
                    level = GetBuildingLevelParamEN(ele);
                }
            }
            else
            {
                if (isPipe)
                {
                    level = GetPipeLevelParamCN(ele);
                }
                else
                {
                    level = GetBuildingLevelParamCN(ele);
                }
            }

            //无法获取Element标高或参照标高参数
            if (string.IsNullOrEmpty(level))
            {
                string errorType = MtCommon.GetStringValue(ErrorType.NoParameter) + MtCommon.GetStringValue(MtGlobals.Parameters.MtLevel) + "或"
                                   + MtCommon.GetStringValue(MtGlobals.Parameters.ReferenceLevel);
                AddListViewErrorData(ele, errorType);
            }

            Parameter param = ele.LookupParameter(MtCommon.GetStringValue(MtGlobals.Parameters.MtLevel));

            if (null != param)
            {
                bool success = param.Set(level);
                if (!success)
                {
                    //楼层参数未设置成功
                    string errorType = MtCommon.GetStringValue(ErrorType.SetParamterFailed) + MtCommon.GetStringValue(MtGlobals.Parameters.MtLevel);
                    AddListViewErrorData(ele, errorType);
                }
            }
            else
            {
                //无法获取Element楼层参数
                string errorType = MtCommon.GetStringValue(ErrorType.NoParameter) + MtCommon.GetStringValue(MtGlobals.Parameters.MtLevel);
                AddListViewErrorData(ele, errorType);
            }
        }
        void IsConsistenSystemName(Element ele)
        {
            bool isconsistent = CheckConnectedElementsIsSameSystemName(ele);

            if (!isconsistent)
            {
                AddListViewErrorData(ele, MtCommon.GetStringValue(ErrorType.InConsistentSystemName));
            }
        }
Example #12
0
        public static void HideElements(Document doc, ICollection <Element> elements)
        {
            List <ElementId> eleIds = new List <ElementId>();

            foreach (var item in elements)
            {
                eleIds.Add(item.Id);
            }
            MtCommon.HideElementsTemporary(doc, eleIds);
        }
        private string GetPipeLevel(Element ele)
        {
            string referenceLevel = string.Empty;

            referenceLevel = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.ReferenceLevel));
            if (string.IsNullOrEmpty(referenceLevel))
            {
                referenceLevel = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Level));
            }
            return(referenceLevel);
        }
        List <string> GetOnePipeSystemNames(Element ele)
        {
            string        systemName     = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.SystemName));
            List <string> eleSystemNames = new List <string>();

            if (!string.IsNullOrEmpty(systemName))
            {
                eleSystemNames = MtCommon.RemoveNumInComplexString(systemName); //可能包含多个系统名称
            }
            return(eleSystemNames);
        }
        string GetBuildingLevelParamCN(Element ele)
        {
            string Level = string.Empty;

            Level = GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Level));
            if (string.IsNullOrEmpty(Level))
            {
                Level = GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.ReferenceLevel));
            }
            return(Level);
        }
Example #16
0
        void AddListViewErrorData(Element ele, string errorType = null)
        {
            string famliyName             = MtCommon.GetElementFamilyName(m_uIDocument.Document, ele);
            string typeName               = MtCommon.GetElementType(m_uIDocument.Document, ele);
            string message                = MtCommon.GetStringValue(ErrorType.NoEndPipe) + errorType;
            SpuriousConnectionError error = CreateBasicInfoError(ele.Id.ToString(), famliyName, typeName, message);

            if (!m_dicErrorList.ContainsKey(ele.Id.ToString()))
            {
                m_dicErrorList.Add(ele.Id.ToString(), error);
            }
        }
        void AddListViewErrorData(Element ele, string errorType)
        {
            string         famliyName = MtCommon.GetElementFamilyName(m_uIDocument.Document, ele);
            string         typeName   = MtCommon.GetElementType(m_uIDocument.Document, ele);
            string         message    = errorType;
            BasicInfoError error      = CreateBasicInfoError(ele.Id.ToString(), famliyName, typeName, message);

            if (!m_ltBasicInfoErrors.ContainsKey(ele.Id))
            {
                m_ltBasicInfoErrors.Add(ele.Id, error);
            }
        }
        private TreeNode GetStartingElementNode(Element selectElement)
        {
            TreeNode startingElementNode = null;

            startingElementNode                = new TreeNode(selectElement.Id);
            startingElementNode.FamilyName     = MtCommon.GetElementFamilyName(m_document, selectElement);
            startingElementNode.TypeName       = MtCommon.GetElementType(m_document, selectElement);
            startingElementNode.Parent         = null;
            startingElementNode.InputConnector = null;
            startingElementNode.Info           = GetElementInfo(selectElement);
            startingElementNode.IsValve        = IsValve(selectElement) ? 1 : 0;
            return(startingElementNode);
        }
 public void HideTraverseElement(Document doc)
 {
     if (m_allTreeNodeList.Count == 0 || m_allTreeNodeList == null)
     {
         return;
     }
     foreach (var treenode in m_allTreeNodeList)
     {
         Element ele = MtCommon.GetElementById(doc, treenode.Id.ToString());
         MtCommon.HideElementTemporary(doc, ele);
     }
     m_allTreeNodeList.Clear();
 }
Example #20
0
        void AddListViewErrorData(Element ele, string errorType = null)
        {
            string            eleId      = ele.Id.ToString();
            string            famliyName = MtCommon.GetElementFamilyName(m_uIDocument.Document, ele);
            string            typeName   = MtCommon.GetElementType(m_uIDocument.Document, ele);
            string            message    = errorType;
            PipeRelationError error      = CreatePipeRelationError(ele.Id.ToString(), famliyName, typeName, message);

            if (!m_dicPipeRelationError.ContainsKey(ele.Id.ToString()))
            {
                m_dicPipeRelationError.Add(eleId, error);
            }
        }
        void ClearEquipmentCode()
        {
            ElementClassFilter       instanceFilter = new ElementClassFilter(typeof(FamilyInstance));
            ElementClassFilter       hostFilter     = new ElementClassFilter(typeof(HostObject));
            LogicalOrFilter          andFilter      = new LogicalOrFilter(instanceFilter, hostFilter);
            FilteredElementCollector collector      = new FilteredElementCollector(m_uIDocument.Document);

            collector.WherePasses(andFilter);

            foreach (var ele in collector)
            {
                MtCommon.SetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.EquipmentCode), string.Empty);
            }
        }
        private void InitLevel()
        {
            if (m_level == null)
            {
                return;
            }
            m_ltCurSystemNames = new List <System.Windows.Controls.CheckBox>();

            SystemComboBox.ItemsSource   = MtCommon.GetEnumAttributeNames(typeof(MtGlobals.SystemName));
            SystemComboBox.SelectedIndex = 0;

            m_ltCurSystemNames          = CreateCheckBox(MtCommon.GetEnumAttributeNames(typeof(MtGlobals.ACSubSystem)));
            StandardSysList.ItemsSource = m_ltCurSystemNames;
        }
        bool IsLevelCorrect(Element ele, string level, string offset, out string errorMsg)
        {
            bool   isLevelCorrect = false;
            string errorMessage   = string.Empty;

            if (!string.IsNullOrEmpty(level) && !string.IsNullOrEmpty(offset))
            {
                double levelOffset = 0;
                if (m_dicLevelOffset.ContainsKey(level))
                {
                    levelOffset = m_dicLevelOffset[level];
                    double offsetValue = double.Parse(offset);

                    if (offsetValue < 0)
                    {
                        //将给排水中的排水管道排除,排水的管道位于本层标高的下方,该排水管道的标高属于本层
                        string systemName = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.SystemName));
                        if (!string.IsNullOrEmpty(systemName) && (systemName.Contains("排水") || systemName.Contains("废水")))
                        {
                            if (offsetValue < 0 && Math.Abs(offsetValue) < levelOffset)
                            {
                                isLevelCorrect = true;
                            }
                            else
                            {
                                isLevelCorrect = false;
                                errorMessage   = MtCommon.GetStringValue(ErrorType.NegLevelOffset);
                            }
                        }
                        else
                        {
                            isLevelCorrect = false;
                            errorMessage   = MtCommon.GetStringValue(ErrorType.NegLevelOffset);
                        }
                    }
                    else if (offsetValue > 0 && offsetValue > levelOffset)
                    {
                        isLevelCorrect = false;
                        errorMessage   = MtCommon.GetStringValue(ErrorType.PosLevelOffset);
                    }
                    else
                    {
                        isLevelCorrect = true;
                    }
                }
            }
            errorMsg = errorMessage;
            return(isLevelCorrect);
        }
        private bool IsValve(Element ele)
        {
            if (ele == null)
            {
                return(false);
            }
            string familyName = MtCommon.GetElementFamilyName(m_document, ele);

            if (!string.IsNullOrEmpty(familyName) && familyName.Contains("阀"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void BasicInfoListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.Source is System.Windows.Controls.ListView)
            {
                BasicInfoError error = BasicInfoListView.SelectedItem as BasicInfoError;

                if (error != null && error is BasicInfoError)
                {
                    string  id      = error.ID;
                    Element element = MtCommon.GetElementById(m_uidoc.Document, id);
                    MtCommon.ElementCenterDisplay(m_uidoc, element);

                    IList <ElementId> list = new List <ElementId>();
                    list.Add(element.Id);
                    m_uidoc.Selection.SetElementIds(list);
                }
            }
        }
        public void MarkLongVerticalPipeOrDust(Element ele, string levelName, string startoffset, string endoffset)
        {
            if (ValideParams(ele, levelName, startoffset, endoffset))
            {
                double LevelOffset  = m_dicLevelOffset[levelName];
                double startoffsetV = double.Parse(startoffset);
                double endoffsetV   = double.Parse(endoffset);

                if (Math.Abs(startoffsetV - endoffsetV) > LevelOffset)   //只有跨楼层的竖管才标记
                {
                    MtCommon.SetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.VerticalPipe), "1-1");
                }
                else
                {
                    MtCommon.SetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.VerticalPipe), "1");
                }
            }
        }
Example #27
0
        void TestLoopCircuit(StartElementData data, Action <List <Element> > totalElments = null)
        {
            ClearErrorListView();

            MtTravelsalTree tree = new MtTravelsalTree(m_uIDocument.Document, data.System);
            List <Element>  eles = tree.TestCircuit(data.StartElement, m_isSameSystem, m_multiSystem, IsIsolatedElements, totalElments);

            if (eles != null && eles.Count != 0)
            {
                foreach (var ele in eles)
                {
                    AddListViewErrorData(ele, MtCommon.GetStringValue(ErrorType.Circuit));
                }
            }
            IList <PipeRelationError> pipeRelationErrors = m_dicPipeRelationError.Select(v => v.Value).ToList();

            pipeRelationErrors = pipeRelationErrors.OrderBy(v => (v.FamilyName + v.TypeName)).ToList();
            SetErrorListView(pipeRelationErrors);
        }
Example #28
0
        bool EleConnectorIsComplete(Element ele)
        {
            ConnectorSet connectors = MtCommon.GetAllConnectors(ele);

            if (connectors != null)
            {
                foreach (Connector item in connectors)
                {
                    if (item.Domain == Domain.DomainElectrical) //去除ElectricalConnector
                    {
                        continue;
                    }

                    if (!item.IsConnected)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        string RenameEleId(Element ele)
        {
            if (ele == null)
            {
                return(string.Empty);
            }

            string district = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Campus));
            string building = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Building));
            string level    = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.MtLevel));

            if (!string.IsNullOrEmpty(district) && !string.IsNullOrEmpty(building) && !string.IsNullOrEmpty(level))
            {
                return(district + "-" + building + "-" + level + "_PD_" + ele.Id);
            }
            else
            {
                TaskDialog.Show("Error", "Basic info is empty : " + ele.Id);
                return(string.Empty);
            }
        }
        private string GetElementInfo(Element ele)
        {
            if (ele == null)
            {
                return(string.Empty);
            }

            string area          = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Campus));
            string building      = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.Building));
            string level         = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.MtLevel));
            string equipmentCode = MtCommon.GetOneParameter(ele, MtCommon.GetStringValue(MtGlobals.Parameters.EquipmentCode));

            string isEquip = "0";

            if (!string.IsNullOrEmpty(equipmentCode))
            {
                isEquip = "1";
            }

            return(area + "-" + building + "-" + level + "*" + isEquip);
        }