Vertical Projection of Beam Analytical Model

We tried to fly from Milano to Paris this evening for the last DevDays conference, but unfortunately our flight was cancelled due to snow in Paris. Now we are stuck at the Milano airport and hoping that the first flight in the morning will not be cancelled as well. If it is, we will not be able to make it at all. Otherwise, we will arrive rather late and have to reschedule the agenda, but at least then we will not be forced to cancel the whole conference. Fervently hoping for the best...

Since I am not sleeping anyway, I may as well post.

First, here are some more titbits from AU:

Kean posted an AU wrap-up with a short video and some snapshots from various Autodesk University experiences.

As part of AUv, Jim Quanci gave a very informative virtual interview on the Autodesk Developer Network ADN which is the part of Autodesk that provides developer support and that I work in. It has now been posted on the AU YouTube channel and...

Getting back to the Revit API, here is a recent case handled by my colleagues Joe Ye and Saikat Bhattacharya which shows how to handle the setting of the vertical projection of the analytical model of a beam. An interesting aspect of this is that the parameter data type is an element id, and yet we are actually storing an enumeration value in it. This is not uncommon in Revit parameters; there are a few of them that can take both element ids to refer to other database objects as well as a fixed set of enumeration values for specific exceptional cases.

Question: How can I set the 'Vertical Projection' parameter of a beam to the 'Center of Beam' value?"

Answer: Here is a description on how to set the vertical projection parameter of a beam.

Start by defining the following enumeration:

enum AnalyticalVerticalProjection_e
{
  AVP_AUTODETECT = -1,
  AVP_TOP_OF_PHYSICAL = -2,
  AVP_CENTER_OF_PHYSICAL = -3,
  AVP_BOTTOM_OF_PHYSICAL = -4,
};

This can be used as follows:

Note that the parameter value can be set successfully to the value, even though it is not a real element id.

Here is a code snippet showing how to set value to top of the slab:

Element e = SelectSlab( "Please select a slab", 
  commandData, typeof( Floor ) );
 
if( null != e )
{
  Floor floor = e as Floor;
 
  BuiltInParameter bip = BuiltInParameter
    .STRUCTURAL_ANALYTICAL_PROJECT_FLOOR_PLANE;
 
  Parameter p = floor.get_Parameter( bip );
 
  ElementId id = p.AsElementId();
 
  // id.Value is negative if the parameter 
  // value is not a real element id:
 
  id.Value = -2; // top of the slab
 
  p.Set( ref id );
}

Thank you Joe and Saikat for this illuminating answer!