TraverseSystem Implements the Revit add-in interface IExternalCommand Implement this method as an external command for Revit. An object that is passed to the external application which contains data related to the command, such as the application object and active view. A message that can be set by the external application which will be displayed if a failure or cancellation is returned by the external command. A set of elements to which the external application can add elements that are to be highlighted in case of failure or cancellation. Return the status of the external command. A result of Succeeded means that the API external method functioned as expected. Cancelled can be used to signify that the user cancelled the external operation at some point. Failure should be returned if the application is unable to proceed with the operation. Get the mechanical or piping system from selected element Selected element The extracted mechanical or piping system. Null if no expected system is found. Get the mechanical or piping system from the connectors of selected element Connectors of selected element The found mechanical or piping system A TreeNode object represents an element in the system Id of the element Flow direction of the node For the starting element of the traversal, the direction will be the same as the connector connected to its following element; Otherwise it will be the direction of the connector connected to its previous element The parent node of the current node. The connector of the previous element to which current element is connected The first-level child nodes of the current node Active document of Revit Id of the element Flow direction of the node Gets and sets the parent node of the current node. Gets and sets the first-level child nodes of the current node The connector of the previous element to which current element is connected Constructor Revit document Element's Id Get Element by its Id Element's Id Element Dump the node into XML file XmlWriter object Data structure of the traversal Constructor Revit document The MEP system to traverse Traverse the system Get the starting element node. If the system has base equipment then get it; Otherwise get the owner of the open connector in the system The starting element node Get the owner of the open connector as the starting element The owner Get the open connector of the system if the system has no base equipment An element in the system The connector of the previous element to which the element is connected The found open connector Traverse the system recursively by analyzing each element The element to be analyzed Find all child nodes of the specified element node The specified element node to be analyzed Get the connected connector of one connector The connector to be analyzed The connected connector Get element by its id Dump the traversal into an XML file Name of the XML file Write basic information of the MEP system into the XML file XMLWriter object Write paths of the traversal into the XML file XMLWriter object