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)); } } }
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); } }
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); } }
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); }
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); } }
bool IsRejectFromCondition(Element ele, string condition) { string FilterCondition = "系统名称"; Parameter param = ele.LookupParameter(FilterCondition); string paramStr = string.Empty; if (param != null) { paramStr = param.AsString(); } if ((!string.IsNullOrEmpty(paramStr) && paramStr.Contains(condition)) || MtCommon.GetElementFamilyName(m_uIDocument.Document, ele).Contains(condition)) { return(true); } else { return(false); } }
public void TravelAllPipe() { ClearDic(); //设置全部管道的基本参数 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); IList <ElementId> notCompleteConnected = new List <ElementId>(); //设置剔除条件 foreach (var item in collector) { //按条件剔除Element string familyName = MtCommon.GetElementFamilyName(m_uIDocument.Document, item); string typeName = MtCommon.GetElementType(m_uIDocument.Document, item); Parameter param = item.LookupParameter("系统名称"); string systemName = string.Empty; if (param != null) { systemName = param.AsString(); } if (IsRemoveFan && ((!string.IsNullOrEmpty(systemName) && systemName.Contains("风盘")) || familyName.Contains("风机盘管") || familyName.Contains("风盘") || typeName.Contains("风机盘管") || typeName.Contains("风盘"))) { continue; } if (IsRemoveCondensorPipe && (IsRejectFromCondition(item, "冷凝水") || MtCommon.GetElementFamilyName(m_uIDocument.Document, item).Contains("冷凝水"))) { continue; } if (IsRemoveAirDust && (item.Category.Name.Contains(MtGlobals.DustCategory) || item.Category.Name.Contains("风管附件") || item.Category.Name.Contains("风管管件") || item.Category.Name.Contains("风道末端"))) { continue; } bool isCompleteConnected = EleConnectorIsComplete(item); if (!isCompleteConnected) { notCompleteConnected.Add(item.Id); AddListViewErrorData(item); } } IList <SpuriousConnectionError> m_ErrorListView = m_dicErrorList.Select(v => v.Value).ToList(); m_ErrorListView = m_ErrorListView.OrderBy(v => (v.FamilyName + v.TypeName)).ToList(); SetErrorListView(m_ErrorListView); }
private void AppendChildren(TreeNode elementNode, bool isSameSystemName = true, string multiSystem = null) { List <TreeNode> nodes = elementNode.ChildNodes; Element element = m_document.GetElement(elementNode.Id); ConnectorSet connectors = MtCommon.GetAllConnectors(element); List <string> systemNames = multiSystem.Split(';').ToList(); foreach (Connector connector in connectors) { MEPSystem mepSystem = connector.MEPSystem; if (isSameSystemName) { Element ele = m_document.GetElement(m_startingElementNode.Id); if (ele.Category.Name.Equals("风道末端") || ele.Category.Name.Equals("风管管件") || ele.Category.Name.Equals("风管") || ele.Category.Name.Equals("风管附件")) //风管中可以存在设备两端系统名称中数字不一致的情况 { if (mepSystem == null || !MtCommon.RemoveNumInString(mepSystem.Name).Equals(MtCommon.RemoveNumInString(m_system.Name))) { continue; } } else //管道的判断,需根据id判断,避免造成供回水,冷凝水全部检测到 { if (mepSystem == null || !mepSystem.Id.IntegerValue.Equals(m_system.Id.IntegerValue)) { continue; } } } else //此种情况是风管中不同系统用相同管道,排风排烟,新风送风,使用相同管道,但是流向是连续的。 { if (multiSystem != null && multiSystem.Length != 0) { if (mepSystem == null || !systemNames.Contains(MtCommon.RemoveNumInString(mepSystem.Name))) { continue; } } //if (mepSystem == null || (mepSystem is MechanicalSystem) && (m_system is PipingSystem) || (mepSystem is PipingSystem) && (m_system is MechanicalSystem)) // continue; } if (elementNode.Parent == null) { if (connector.IsConnected) { elementNode.Direction = connector.Direction; } } else { if (connector.IsConnectedTo(elementNode.InputConnector)) { elementNode.Direction = connector.Direction; continue; } } Connector connectedConnector = MtCommon.GetConnectedConnector(connector); if (connectedConnector != null) { TreeNode node = new TreeNode(connectedConnector.Owner.Id); node.FamilyName = MtCommon.GetElementFamilyName(m_document, connectedConnector.Owner); node.TypeName = MtCommon.GetElementType(m_document, connectedConnector.Owner); node.InputConnector = connector; node.Parent = elementNode; node.Info = GetElementInfo(m_document.GetElement(node.Id)); node.IsValve = IsValve(m_document.GetElement(node.Id)) ? 1 : 0; nodes.Add(node); } } nodes.Sort(delegate(TreeNode t1, TreeNode t2) { return(t1.Id.IntegerValue > t2.Id.IntegerValue ? 1 : (t1.Id.IntegerValue < t2.Id.IntegerValue ? -1 : 0)); } ); }