BimRv SDK: Work with MEP Connectors

Ilya Kovaldov

June 04, 2021

Introduction

Connectors are logical entities and a part of other elements that allow components containing connectors to interact correctly within the system topology. They are represented by the OdBmConnector class.

Get the Domain Type

To receive the domain type of a connector, use the getDomainType() method. The possible values are defined in the OdBm::ConnectorDomainType::Enum enumeration:

  • DomainUndefined — Domain type of the connector is undefined.
  • DomainHvac — HVAC/duct connector.
  • DomainElectrical — Electrical connector.
  • DomainPiping — Piping connector.
  • DomainCableTrayConduit — Cable tray conduits connector.
  • DomainStructuralAnalytical — Structural analytical model connector.
Get the Connection Type

To receive the connection type of a connector, use the getConnectorType() method. The possible values are defined in the OdBm::ConnectorTypes::Enum enumeration:

  • Invalid — Invalid connection type.
  • End — End connection type.
  • Curve — Curve connection type.
  • Logical — Logical connection type.
  • Reference — Reference connection type.
  • Surface — Surface connection type.
  • EndSurface — End or surface connection type.
  • Physical — Physical connection type.
  • NonEnd — Non-end connection type.
  • MasterSurface — Master surface connection type.
  • Family — Family connection type.
  • NodeReference — Reference to the layout node.
  • BlankEnd — Blank end connection type.
  • AnyEnd — Any end connection type.
  • Super — Super connection type.
  • AllModes — All connection types.

The physical connection type includes End, Curve and Surface. To check whether a connection type is physical, use the isPhysicalConnector() method.

Get the Flow Direction

The connection flow direction is supported only for HVAC and piping connectors.

To receive the flow direction of a connector, use the getDirection() method. The possible values are defined in the OdBm::FlowDirectionType::Enum enumeration:

  • Bidirectional — Bidirectional flow direction.
  • In — Input flow direction.
  • Out — Output flow direction.

For domain types other than HVAC and piping connectors, the function returns OdResult::eNotApplicable. The function also returns an error if the direction cannot be calculated.

Get the System of a Connector

A connector can belong to an MEP system. To receive an identifier of this system, use the getMEPSystem() method. If a connector is in a system, the function puts the identifier of the system into an systemId argument and returns OdResult::eOk, or it returns OdResult::eNotApplicable if a connector is not in a system.

Get the Connector Manager

To receive the Connector Manager of the connector, use the getConnectorManager() method. This member function returns the Connector Manager of the connector or NULL if the connector has no owner element.

Check Connection

To check whether a connector has a physical connection with another element, use the isConnected() method. This function returns true if the connector is connected to another element. This function works with physical connectors only.

Get the Connector Coordinate System

To receive the connector coordinate system, its location, and orientation in space, use the getCoordinateSystem method. This function puts the connector coordinate system into the connectorCS argument and returns OdResult::eOk if the coordinate system is retrieved successfully, or it returns OdResult::eNotApplicable otherwise. This function works with physical connectors only. The connector location can be calculated if you assume the origin of connectorCS as a reference point, and the z-axis should be normal to the connector.

Example

The following code sample contains templates with notes for applying all the functions described above.

//   opening some family instance element.
//   there can be any type of element with connectors:
//   FamilyInstance, RbsCurve, RbsSystem, etc.
OdBmFamilyInstancePtr famInst = pDb->getObjectId(OdDbHandle(handle)).safeOpenObject();
if (famInst.isNull())
{
  pIO->putString(OD_T("Invalid handle"));
  return;
}
OdBm::ConnectorDomainType::Enum conDomainType;
OdBm::ConnectorTypes::Enum conType;
OdBm::FlowDirectionType::Enum conFlowDirection;
bool isPhysical;
bool isConnected;
OdBmConnectorManagerPtr pConManager;
OdGeMatrix3d conCoordSystem;
OdBmConnectorPtrArray connectors;
OdResult result;
OdBmObjectId connectorSystemId;
// getting connectors via element connector manager
famInst->getBaseConnectorManager()->getConnectors(connectors);
// processing connectors
for (auto connector : connectors)
{
  // 1. Getting domain type
  conDomainType = connector->getDomainType();
  if (conDomainType == OdBm::ConnectorDomainType::DomainPiping)
  {
    // do some actions in case of Piping connector
  }
  // 2. Getting connection type
  conType = connector->getConnectorType();
  if (conType == OdBm::ConnectorTypes::Logical)
  {
    // do some actions in case of Logical connection
  }
  // 3. Check if physical connector
  isPhysical = connector->isPhysicalConnector();
  if (!isPhysical)
  {
    // do some actions in case of Non-physical connector
  }
  // 4. Getting connection flow direction
  result = connector->getDirection(conFlowDirection);
  if (result == eOk && conFlowDirection == OdBm::FlowDirectionType::Out)
  {
    // do some actions in case of calculated Out flow direction
  }
  // 5. Getting connector MEP system
  result = connector->getMEPSystem(connectorSystemId);
  if (result == eOk)
  {
    OdBmRbsSystemPtr pMEPSystem = connectorSystemId.safeOpenObject();
    if (!pMEPSystem.isNull())
    {
      // do some actions with connector MEP system
    }
  }
  // 6. Getting connector manager
  pConManager = connector->getConnectorManager();
  if (!pConManager.isNull())
  {
    // do some actions with connector ConnectorManager
  }
  // 7. Checking if connector connected to another element
  isConnected = connector->isConnected();
  if (isConnected)
  {
    // do some actions if connector identified as connected
  }
  // 8. Getting connector location
  result = connector->getCoordinateSystem(conCoordSystem);
  if (result == eOk)
  {
    OdGePoint3d connectorOrigin = conCoordSystem.getCsOrigin();
    OdGeVector3d connectorNormal = conCoordSystem.getCsZAxis();
    // do some actions with connector location
  }
}