Connector Direction and CreateAirHandler Sample

Here is an update to the CreateAirHandler SDK sample provided by my colleague Greg Wesner together with an interesting analysis of MEP connector directions.
<!–
156_mep_2010_api.htm:

  • CreateAirHandler:</st
    199_family_api.htm:

    CreateAirHandler – RME

    199_family_api.htm:

    CreateAirHandler is a Revit MEP
    219_mep_api.htm:

  • CreateAirHandler: Create an air ha
    362_mep_2011_api.htm:
  • CreateAirHandler
    130_mep_connectors.htm
    204_rvtmgddbg_mep_connectors.htm
    312_connector_orientation.htm
    407_modeless_loose_connectors.htm
    398_retrieve_mep_elements.htm
    –>

    We looked at various aspects of MEP connectors several times in the past:

    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:

    Current CreateAirHandler result

    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:

    Correct CreateAirHandler result

    Here is
    Command.cs
    containing the corrected command implementation, and the
    diffs, i.e. the changes I made to
    fix these issues.

    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:

    Connectors point outwards in Revit 2010

    Running the exact same code in Revit 2011, however, causes them to point inwards instead:

    Connectors point inwards in Revit 2011

    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[0] to m_planarFaces[1].
    That affects the following line for the supply air connector:

    
      // create the Supply Air duct connector
      DuctConnector connSupplyAir
        = f.NewDuctConnector(
          m_planarFaces[1].Reference,
          DuctSystemType.SupplyAir );
    

    Similarly, the following line for the return air connector:

    
      // create the Return Air duct connector
      DuctConnector connReturnAir
        = f.NewDuctConnector(
          m_planarFaces[1].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.


  • Comments

    3 responses to “Connector Direction and CreateAirHandler Sample”

    1. sangsen Avatar
      sangsen

      Hi jeremy..
      I need revitlookup for revit 2010(not avail in SDK 2010)

    2. Dear Sangsen,
      Thank you for your query.
      RevitLookup was named RvtMgdDbg in the Revit 2010 timeframe.
      I updated the post on RvtMgdDbg for Revit 2010 for you:
      http://thebuildingcoder.typepad.com/blog/2009/10/rvtmgddbg-for-revit-2010.html
      It now includes the full source code as well as a compiled version.
      Cheers, Jeremy.

    3. sangsen Avatar
      sangsen

      Thanks Jeremy

    Leave a Reply

    Discover more from Autodesk Developer Blog

    Subscribe now to keep reading and get access to the full archive.

    Continue reading