Here is an update to the CreateAirHandler SDK sample provided by my colleague Greg Wesner together with an interesting analysis of MEP connector directions.
We looked at various aspects of MEP connectors several times in the past:
- The difference between the family connector elements and the project connector class.
- Enhancing RevitLookup for MEP, previously known as RvtMgdDbg.
- Connector orientation.
- Retrieving MEP elements and connectors.
- Modeless loose connector navigator.
The CreateAirHandler SDK sample shows how to create an MEP air handling device including its connectors. It was introduced with the Revit MEP 2010 API and is also a family API sample. We since also discussed the Revit MEP API in general and the current situation in the Revit MEP 2011 API.
Here are Greg's observations and fixes:
I found some issues with the CreateAirHandler SDK sample that are easy to fix. Here is an image of the family as it is generated by the current sample implementation:
Notice that the supply and return connectors and voids are not on the extruded solid that represents the air handler itself. Neither is the top hydronic supply. If you look at the supply connector (the smaller green rectangle), it should be in the same plane as the orange void. And it s hard to see here, but the direction indicator for the return connector is pointing in the wrong direction. Here is what I think it should look like:
Connector Direction Reversal
I originally implemented this update based on Revit 2010. When I tested the same code on Revit 2011, I noticed is that the connector direction changed between Revit 2010 and 2011.
After I fixed the air handler creation to my satisfaction for the 2010 version, the connectors point outwards as I expect:
Running the exact same code in Revit 2011, however, causes them to point inwards instead:
Note that the arrows for the supply and return connectors point inward in 2011. That's actually the opposite of the normal for the face of the object they are attached to. I verified this using Revit Lookup and looking at the normal of the faces I attach to.
I also notice that the hydronic connectors at the bottom didn't change. The only thing I can think of is that the supply and return ducts actually attach to a void extrusion whereas the hydronic connectors attach to a solid. I guess that Revit inverts the normal for the connector when it is attached to a void extrusion? That would explain why the arrows are reversed for the air connectors.
Reverse the Reversal
This leads to an additional fix:
In the initial code update, I changed the face that the connector is associated with to the outside face of the void extrusions. This results in the direction indicator pointing in towards the centre of the air handler in Revit 2011.
In order to keep them pointing outwards, you may want to associate the opposite face instead. To do so, in the CreateConnectors method, change m_planarFaces to m_planarFaces. That affects the following line for the supply air connector:
// create the Supply Air duct connector DuctConnector connSupplyAir = f.NewDuctConnector( m_planarFaces.Reference, DuctSystemType.SupplyAir );
Similarly, the following line for the return air connector:
// create the Return Air duct connector DuctConnector connReturnAir = f.NewDuctConnector( m_planarFaces.Reference, DuctSystemType.ReturnAir);
This will put the connectors on the inside faces of the voids, but at least the direction arrow will point in the correct direction. Normally, of course, one would expect the connector to be on the exterior of the unit.