New Room Computation Parameters

Isidoro Aguilera of
Aplicad submitted a
comment asking
how to migrate code making use of some room computation parameters from the Revit 2011 API to Revit 2012, specifically the built-in parameters

  • LEVEL_ATTR_ROOM_COMPUTATION_AUTOMATIC
  • LEVEL_ATTR_ROOM_COMPUTATION_HEIGHT

Question: I’m migrating a plug-in from 2011 and 2012 and experienced problems with the level type parameters BuiltInParameter.LEVEL_ATTR_ROOM_COMPUTATION_AUTOMATIC and BuiltInParameter.LEVEL_ATTR_ROOM_COMPUTATION_HEIGHT.
They were writable in Revit 2011, but are read-only in Revit 2012.

Have you experienced a similar issue when migrating your samples?

The following code worked in Revit 2011, and fails in 2012:


  FilteredElementCollector collector
    = new FilteredElementCollector( App.Document );
 
  IList elementos = collector
    .OfCategory( BuiltInCategory.OST_Levels )
    .WhereElementIsElementType()
    .ToElements();
 
  foreach( Element e in elementos )
  {
    Parameter p = e.get_Parameter( BuiltInParameter
      .LEVEL_ATTR_ROOM_COMPUTATION_AUTOMATIC );
 
    p.Set( 0 );
 
    p = e.get_Parameter( BuiltInParameter
      .LEVEL_ATTR_ROOM_COMPUTATION_HEIGHT );
 
    p.Set( 0 );
  }
 

Answer: In Revit 2012, levels no longer have the type parameters that existed in prior versions, and both the parameters you name are obsolete.
Instead of using LEVEL_ATTR_ROOM_COMPUTATION_HEIGHT, you can now use LEVEL_ROOM_COMPUTATION_HEIGHT like this:


      FilteredElementCollector collector
        = new FilteredElementCollector(
          uidoc.Document );
 
      IList<Element> elementos = collector
        .OfClass( typeof( Level ) )
        .ToElements();
 
      foreach( Element e in elementos )
      {
        Parameter p = e.get_Parameter( BuiltInParameter
          .LEVEL_ROOM_COMPUTATION_HEIGHT );
 
        p.Set( 2.5 );
      }
 

For setting the room height, you can use ROOM_COMPUTATION_HEIGHT.
The functionality around LEVEL_ATTR_ROOM_COMPUTATION_AUTOMATIC is totally unsupported now.


Comments

2 responses to “New Room Computation Parameters”

  1. Jeremy,
    What would be your solution to not being able to Place more Rooms in a Revit floor plan? Even though there are more room bounded spaces, but you get the Room placing mouse over message in a room space “Not Enclosed” followed by a popup warning “Room Computations Failed”. All warnings have been cleaned up and still this problem persists. No duplicate rooms, no not placed rooms on schedule, no overlapping walls or overlapping room separating lines. Copied and pasted entire model into a new project. Same problem.

  2. Dear J,
    First of all, I would take a look at the Document.NewRooms2 method.
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading