前言
这个例子介绍如何用 Revit API 创建自动路由,本质上就是通过 API 创建机电管道。
内容
将出风口和风机自动连接,最终效果。
下面按步骤将其组装起来:
风机立管及连接件
生成红框内容的核心逻辑:
ducts.Add(Duct.Create(m_document, ductTypeId, lvl.Id,conns[0], points[0]));
ducts.Add(Duct.Create(m_document, systemTypeId, ductTypeId, lvl.Id, points[1], points[2]));
connectors.Add(ConnectorInfo.GetConnector(ducts[0].Id.IntegerValue, points[0]));
connectors.Add(ConnectorInfo.GetConnector(ducts[1].Id.IntegerValue, points[1]));
connectors.Add(ConnectorInfo.GetConnector(ducts[1].Id.IntegerValue, points[2]));
connectors[0].ConnectTo(connectors[1]);
m_document.Create.NewElbowFitting(connectors[0], connectors[1]);
风口立管
生成红框内容的核心逻辑:
points.Add(new GXYZ(conns[1].Origin.X, conns[1].Origin.Y, maxZ + verticalTrunkOffset - min1FittingLength));
points.Add(new GXYZ(conns[2].Origin.X, conns[2].Origin.Y, maxZ + verticalTrunkOffset - min1FittingLength));
ducts.Add(Duct.Create(m_document, ductTypeId, lvl.Id, conns[1], points[0]));
ducts.Add(Duct.Create(m_document, ductTypeId, lvl.Id, conns[2], points[1]));
baseConnectors.Add(ConnectorInfo.GetConnector(ducts[0].Id.IntegerValue, points[0]));
baseConnectors.Add(ConnectorInfo.GetConnector(ducts[1].Id.IntegerValue, points[1]));
生成一条水平风管
生成红框内容的核心逻辑:
connectors = CreateDuct(new GXYZ(baseConnectors[0].Origin.X + min1FittingLength, baseY, baseZ), new GXYZ(baseConnectors[2].Origin.X - min1FittingLength, baseY, baseZ));
生成另外两根水平风管及连接件
生成红框内容的核心逻辑:
ConnectWithTeeFittingOnXAxis(baseConnectors[0], baseConnectors[1], connectors[0], true);
生成最后一个水平风管及连接件
生成红框内容的核心逻辑:
ConnectWithElbowFittingOnXAxis(baseConnectors[2], connectors[1]);