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
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.