Revit API を使用して、新しい配管および機械システムを作成できます。NewPipingSystem()および NewMechanicalSystem()の両方は、配管システムの温水ヒーターや機械システムのファンのように基準設備の接続である Connector を取ります。また、配管システムの洗面台の蛇口など、システムに追加される接続の ConnectorSet も取得します。新しいシステムを作成するために必要な最新の情報は NewPipingSystem()の PipeSystemType、または NewMechanicalSystem()の DuctSystemType のどちらかになります。
次の例では、新しい SupplyAir ダクト システムが、機械設備(たとえば、ファンなど)の選択部分や、選択したすべてのエアターミナルから作成されています。
コード領域 30-4: 新しい機械システムを作成 |
// create a connector set for new mechanical system ConnectorSet connectorSet = new ConnectorSet(); // Base equipment connector Connector baseConnector = null; // Select a Parallel Fan Powered VAV and some Supply Diffusers // prior to running this example ConnectorSetIterator csi = null; ICollection<ElementId> selectedIds = uiDocument.Selection.GetElementIds(); Document document = uiDocument.Document; foreach (ElementId id in selectedIds) { Element e = document.GetElement(id); if (e is FamilyInstance) { FamilyInstance fi = e as FamilyInstance; Family family = fi.Symbol.Family; // Assume the selected Mechanical Equipment is the base equipment for new system if (family.FamilyCategory.Name == "Mechanical Equipment") { //Find the "Out" and "SupplyAir" connector on the base equipment if (null != fi.MEPModel) { csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator(); while (csi.MoveNext()) { Connector conn = csi.Current as Connector; if (conn.Direction == FlowDirectionType.Out && conn.DuctSystemType == DuctSystemType.SupplyAir) { baseConnector = conn; break; } } } } else if (family.FamilyCategory.Name == "Air Terminals") { // add selected Air Terminals to connector set for new mechanical system csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator(); csi.MoveNext(); connectorSet.Insert(csi.Current as Connector); } } } MechanicalSystem mechanicalSys = null; if (null != baseConnector && connectorSet.Size > 0) { // create a new SupplyAir mechanical system mechanicalSys = uiDocument.Document.Create.NewMechanicalSystem(baseConnector, connectorSet, DuctSystemType.SupplyAir); } |