public MEPRevitEdge(int index, MEPRevitNode owner, MEPRevitNode next, MEPPathDirection direction) : this() { ThisConnectorIndex = index; NextNode = next; ThisNode = owner; Direction = direction; }
public MEPRevitNode NewSection(string name) { var sectionNode = new MEPRevitNode(); sectionNode.AsAbstractNode.Name = name; sectionNode.AsElementNode.Name = name; return(sectionNode);; }
/// <summary> /// Adds a sectional connected to an element /// </summary> /// <param name="elm"></param> /// <returns></returns> public MEPRevitNode NewSection(Element elm, gmdl.MEPEdgeTypes edgeType) { var sectionNode = new MEPRevitNode(); if (elm != null) { var intNode = AddElement(elm); var cl = AddConnection(sectionNode, intNode, MEPPathConnectionType.SectionOf, edgeType); } return(sectionNode); }
/// <summary> /// Add a node to the graph /// </summary> /// <param name="node"></param> /// <param name="merge">Don't add the node if it already exists</param> public void AddNode(MEPRevitNode node, bool merge = true) { var fromElmId = node.OriginId; if (!ElementNodes.ContainsKey(fromElmId)) { var hs = new HashSet <MEPRevitNode>(); hs.Add(node); ElementNodes.Add(fromElmId, hs); } else if (!merge || !ElementNodes[fromElmId].Contains(node)) { ElementNodes[fromElmId].Add(node); } }
/// <summary> /// Create a node for an element /// </summary> /// <param name="Element"></param> /// <param name="merge">Reuse existing nodes for this element</param> /// <returns></returns> public MEPRevitNode AddElement(Element Element, bool merge = true) { var fromElmId = Element != null ? Element.Id.IntegerValue : -1; MEPRevitNode conn1Node = null; if (merge && ElementNodes.ContainsKey(fromElmId)) { conn1Node = ElementNodes[fromElmId].FirstOrDefault(); } if (conn1Node == null) { conn1Node = new MEPRevitNode(Element); AddNode(conn1Node, merge); } return(conn1Node); }
/// <summary> /// Add a connection between two nodes /// </summary> /// <param name="fromNode"></param> /// <param name="toNode"></param> /// <param name="connectionType"></param> /// <param name="edgeType"></param> /// <returns></returns> public MEPRevitEdge AddConnection(MEPRevitNode fromNode, MEPRevitNode toNode, MEPPathConnectionType connectionType, gmdl.MEPEdgeTypes edgeType) { AddNode(fromNode); AddNode(toNode); var cnEdge = fromNode.Connections.FirstOrDefault(cn => cn.ConnectionType == connectionType && cn.AsNodeEdge.EdgeType == edgeType && cn.NextNode == toNode); if (cnEdge == null) { cnEdge = toNode.Connections.FirstOrDefault(cn => cn.ConnectionType == connectionType && cn.AsNodeEdge.EdgeType == edgeType && cn.NextNode == fromNode); } if (cnEdge == null) { cnEdge = new MEPRevitEdge(toNode.OriginId, fromNode, toNode, MEPPathDirection.In); cnEdge.ConnectionType = connectionType; cnEdge.AsNodeEdge.EdgeType = edgeType; cnEdge.SystemId = -1; fromNode.Connections.Add(cnEdge); toNode.Connections.Add(cnEdge); } return(cnEdge); }
/// <summary> /// Connect two connectors together /// </summary> /// <param name="conn1"></param> /// <param name="conn2"></param> /// <param name="connectionType"></param> /// <returns></returns> public MEPRevitEdge AddConnection(Connector conn1, Connector conn2, MEPPathConnectionType connectionType, gmdl.MEPEdgeTypes edgeType) { //direction should always be conn1 IN_TO conn2 if ((conn1.Domain == Autodesk.Revit.DB.Domain.DomainPiping || conn1.Domain == Autodesk.Revit.DB.Domain.DomainHvac) && conn1.Direction == FlowDirectionType.In) { //swap over references var tempConn1 = conn1; conn1 = conn2; conn2 = tempConn1; } MEPRevitNode conn1Node = AddElement(conn1.Owner); MEPRevitNode conn2Node = AddElement(conn2.Owner); MEPRevitEdge connEdge = null; #if REVIT2016 connEdge = conn1Node.Connections.FirstOrDefault(ed => ed.ConnectionType == connectionType && ed.ThisConnectorIndex == conn1.Id && ed.NextNode == conn2Node && ed.NextConnectorIndex == conn2.Id); #else throw new Exception("Only supported in Revit 2016 onwards"); #endif if (connEdge == null) { #if REVIT2016 connEdge = conn2Node.Connections.FirstOrDefault(ed => ed.ConnectionType == connectionType && ed.ThisConnectorIndex == conn2.Id && ed.NextNode == conn1Node && ed.NextConnectorIndex == conn1.Id); #endif } if (connEdge == null) { #if REVIT2016 connEdge = new MEPConnectorNodeEdge(conn1.Id, conn1Node, conn2Node, conn1.Domain == Autodesk.Revit.DB.Domain.DomainHvac || conn1.Domain == Autodesk.Revit.DB.Domain.DomainPiping ? (MEPPathDirection)(int)conn1.Direction : MEPPathDirection.Indeterminate); #else throw new Exception("Only supported in Revit 2016 onwards"); #endif conn1Node.Connections.Add(connEdge); conn2Node.Connections.Add(connEdge); connEdge.ThisConnectorIndex = conn1.Id; connEdge.NextConnectorIndex = conn2.Id; connEdge.ThisOrigin = conn1.Origin; connEdge.NextOrigin = conn2.Origin; connEdge.NextNode = conn2Node; } var ow = conn1.Owner; if (ow != null) { var scp = ow.get_Parameter(BuiltInParameter.RBS_SYSTEM_CLASSIFICATION_PARAM); var sct = ow.get_Parameter(BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM); var scn = ow.get_Parameter(BuiltInParameter.RBS_SYSTEM_NAME_PARAM); if (scp != null) { connEdge.SetWeight("System Classification", scp.AsString()); } if (sct != null) { var st = sct.AsValueString(); connEdge.SetWeight("System Type", st); if (!string.IsNullOrEmpty(st)) { connEdge.AsNodeEdge.TypeLabel = "FL_" + st.ToUpper().Replace(" ", "_"); } } if (scn != null) { connEdge.SetWeight("System Name", scn.AsString()); } } connEdge.ConnectionType = connectionType; connEdge.SystemId = conn1.MEPSystem != null ? conn1.MEPSystem.Id.IntegerValue : -1; connEdge.Description = conn1.Description; //connEdge.Length = MEPGraphParserConnectors.GetDistanceBetweenConnectors(conn1, conn2); connEdge.AsNodeEdge.EdgeType = edgeType; if (conn1.Domain == Autodesk.Revit.DB.Domain.DomainHvac || conn1.Domain == Autodesk.Revit.DB.Domain.DomainPiping) { connEdge.Flow = conn1.Flow; } if (conn1.MEPSystem != null && !Systems.Contains(conn1.MEPSystem.Id.IntegerValue)) { Systems.Add(conn1.MEPSystem.Id.IntegerValue); } if (conn2.MEPSystem != null && !Systems.Contains(conn2.MEPSystem.Id.IntegerValue)) { Systems.Add(conn2.MEPSystem.Id.IntegerValue); } if (conn1.MEPSystem != null) { connEdge.SetWeight("SystemName", conn1.MEPSystem.Name); } else if (conn2.MEPSystem != null) { connEdge.SetWeight("SystemName", conn2.MEPSystem.Name); } return(connEdge); }
public MEPConnectorNodeEdge(int index, int systemId, MEPRevitNode owner, MEPRevitNode next, MEPPathDirection direction) : base(index, systemId, owner, next, direction) { }
public MEPRevitEdge(int index, int systemId, MEPRevitNode owner, MEPRevitNode next, MEPPathDirection direction) : this(index, owner, next, direction) { SystemId = SystemId; }