| | |
| | | using Autodesk.Revit.DB;
|
| | | using Autodesk.Revit.DB.Plumbing;
|
| | | using Autodesk.Revit.UI;
|
| | | using DevExpress.Internal.WinApi.Windows.UI.Notifications;
|
| | | using HStation.RevitDev.RevitDataExport.Common;
|
| | | using HStation.RevitDev.RevitDataExport.Entity;
|
| | | using HStation.RevitDev.RevitDataExport.Forms;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Diagnostics;
|
| | | using System.Linq;
|
| | | using System.Windows.Forms;
|
| | |
|
| | | namespace HStation.RevitDev.RevitDataExport.Utility
|
| | | {
|
| | | public class SystemCheckUtils
|
| | | {
|
| | | public static void SystemCheck(ExternalCommandData data)
|
| | | public static Dictionary<CheckResultType, List<ElementId>> SystemCheck(ExternalCommandData data)
|
| | | {
|
| | | UIDocument uidoc = data.Application.ActiveUIDocument;
|
| | | Document doc = uidoc.Document;
|
| | | List<ElementId> ids = new List<ElementId>();
|
| | | foreach (var id in GlobalResource.ElementIds)
|
| | | |
| | | Dictionary<CheckResultType, List<ElementId>> retDict = new Dictionary<CheckResultType, List<ElementId>>();
|
| | | var ids = new List<ElementId>();
|
| | | |
| | | foreach (var id in GlobalResource.RevitModels.GetIds())
|
| | | {
|
| | | var element = doc.GetElement(new ElementId(int.Parse(id)));
|
| | | var elemId = new ElementId(int.Parse(id));
|
| | | var element = doc.GetElement(elemId);
|
| | | if (element == null) { continue; }
|
| | |
|
| | | bool checkResult = CheckElement(element);
|
| | | bool checkResult = CheckElement(element, out CheckResultType errorType);
|
| | |
|
| | | if (!checkResult)
|
| | | {
|
| | | ids.Add(new ElementId(int.Parse(id)));
|
| | | if (!retDict.ContainsKey(errorType))
|
| | | {
|
| | | retDict.Add(errorType, new List<ElementId>());
|
| | | }
|
| | | retDict[errorType].Add(elemId);
|
| | | }
|
| | | }
|
| | | uidoc.Selection.SetElementIds(ids);
|
| | | //uidoc.Selection.SetElementIds(ids);
|
| | |
|
| | | return retDict;
|
| | | }
|
| | |
|
| | | private static bool CheckElement(Element element)
|
| | | internal static void ShowCheckResult(UIApplication m_uiapp, Dictionary<CheckResultType, List<ElementId>> checkResult)
|
| | | {
|
| | | var revitHandle = Process.GetCurrentProcess().MainWindowHandle;
|
| | | Form_SystemCheckResult result = new Form_SystemCheckResult(m_uiapp, checkResult);
|
| | | result.Show(new WindowHandle(revitHandle));
|
| | | }
|
| | |
|
| | | private static bool CheckElement(Element element, out CheckResultType errorType)
|
| | | {
|
| | | errorType = CheckResultType.CRT_Unknown;
|
| | |
|
| | | //管道两端都必须有节点构件连接
|
| | | if (element is Pipe pipe)
|
| | | {
|
| | | var connectors = pipe.ConnectorManager.Connectors;
|
| | | foreach (Connector connector in connectors)
|
| | | foreach (Autodesk.Revit.DB.Connector connector in connectors)
|
| | | {
|
| | | var connectElems = connector.GetConnectorElements();
|
| | | if (connectElems.Count < 1)
|
| | | {
|
| | | errorType = CheckResultType.CRT_PipeConnectorOpen;
|
| | | return false;
|
| | | }
|
| | |
|
| | | var fi = connectElems[0] as FamilyInstance;
|
| | | if (fi == null) { return false; }
|
| | | if (fi == null) |
| | | {
|
| | | errorType = CheckResultType.CRT_Unknown;
|
| | | return false; |
| | | }
|
| | |
|
| | | foreach (var elem in connectElems)
|
| | | {
|
| | | var id = elem.Id.IntegerValue.ToString();
|
| | | if (!GlobalResource.ElementIds.Contains(id))
|
| | | if (!GlobalResource.RevitModels.Contains(id))
|
| | | {
|
| | | errorType = CheckResultType.CRT_PipeConnectorOpen;
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
| | | ConnectorSet connectors = mepModel.ConnectorManager?.Connectors;
|
| | | if (connectors == null) { return true; }
|
| | |
|
| | | foreach(Connector connector in connectors)
|
| | | foreach(Autodesk.Revit.DB.Connector connector in connectors)
|
| | | {
|
| | | var connectElems = connector.GetConnectorElements();
|
| | | foreach (var connectElem in connectElems)
|
| | | {
|
| | | if (connectElem is FamilyInstance)
|
| | | {
|
| | | errorType = CheckResultType.CRT_NodeConnectNode;
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | errorType = CheckResultType.CRT_Unknown;
|
| | | return false;
|
| | | }
|
| | | }
|