简介
连接器是逻辑实体,是其他元素的一部分,允许包含连接器的组件在系统拓扑中正确交互。它们由 OdBmConnector 类表示。
获取域类型
要获取连接器的域类型,请使用 getDomainType() 方法。可能的值在 OdBm::ConnectorDomainType::Enum 枚举中定义:
- DomainUndefined — 连接器的域类型未定义。
- DomainHvac — HVAC/风管连接器。
- DomainElectrical — 电气连接器。
- DomainPiping — 管道连接器。
- DomainCableTrayConduit — 电缆桥架导管连接器。
- DomainStructuralAnalytical — 结构分析模型连接器。
获取连接类型
要获取连接器的连接类型,请使用 getConnectorType() 方法。可能的值在 OdBm::ConnectorTypes::Enum 枚举中定义:
- Invalid — 无效连接类型。
- End — 末端连接类型。
- Curve — 曲线连接类型。
- Logical — 逻辑连接类型。
- Reference — 参照连接类型。
- Surface — 曲面连接类型。
- EndSurface — 末端或曲面连接类型。
- Physical — 物理连接类型。
- NonEnd — 非末端连接类型。
- MasterSurface — 主曲面连接类型。
- Family — 族连接类型。
- NodeReference — 布局节点的参照。
- BlankEnd — 空白末端连接类型。
- AnyEnd — 任意末端连接类型。
- Super — 超级连接类型。
- AllModes — 所有连接类型。
物理连接类型包括末端、曲线和曲面。要检查连接类型是否为物理类型,请使用 isPhysicalConnector() 方法。
获取流向
连接流向仅支持 HVAC 和管道连接器。
要获取连接器的流向,请使用 getDirection() 方法。可能的值在 OdBm::FlowDirectionType::Enum 枚举中定义:
- Bidirectional — 双向流向。
- In — 输入流向。
- Out — 输出流向。
对于 HVAC 和管道连接器以外的域类型,该函数返回 OdResult::eNotApplicable。如果无法计算方向,该函数还会返回错误。
获取连接器的系统
连接器可以属于 MEP 系统。要获取此系统的标识符,请使用 getMEPSystem() 方法。如果连接器在系统中,该函数会将系统标识符放入 systemId 参数并返回 OdResult::eOk;如果连接器不在系统中,则返回 OdResult::eNotApplicable。
获取连接器管理器
要获取连接器的连接器管理器,请使用 getConnectorManager() 方法。如果连接器没有所有者元素,此成员函数将返回连接器的连接器管理器或 NULL。
检查连接
要检查连接器是否与另一个元素有物理连接,请使用 isConnected() 方法。如果连接器连接到另一个元素,此函数将返回 true。此函数仅适用于物理连接器。
获取连接器坐标系
要获取连接器坐标系、其位置和空间方向,请使用 getCoordinateSystem 方法。如果成功检索到坐标系,此函数会将连接器坐标系放入 connectorCS 参数并返回 OdResult::eOk,否则返回 OdResult::eNotApplicable。此函数仅适用于物理连接器。如果将 connectorCS 的原点视为参考点,并且 z 轴应垂直于连接器,则可以计算连接器位置。
示例
以下代码示例包含模板,其中附有应用上述所有功能的说明。
// 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
}
}