Description
In RevitAPI not all objects have exposed parameters as properties. Some basic level properties can be directly accessed using the getter (e.g. the element name, level name), but other elements are more complicated because they are not directly defined but they descend directly from a base class (FamilyInstance). Both windows and doors are familyinstances, the difference in the type of parameters they have and their category.
For these elements to access a parameter value you have to use the Element method “get_Parameter”.
Links
Built In Parameter – n enumerated type listing all of the built-in parameter IDs supported by Autodesk Revit.
Element – Base class for most persistent data within a Revit document.
ElementId – The ElementId object is used as a unique identification for an element within a single project.
Implementation
//room area Parameter parameter = element.get_Parameter(BuiltInParameter.ROOM_AREA); double area = (parameter.HasValue) ? parameter.AsDouble() : 0; //room perimeter Parameter parameter = element.get_Parameter(BuiltInParameter.ROOM_PERIMETER); double perimeter = (parameter.HasValue) ? parameter.AsDouble() : 0; //room phase Parameter parameter = room.get_Parameter(BuiltInParameter.ROOM_PHASE); ElementId phaseId = (parameter.HasValue) ? parameter.AsElementId() : null; if (phaseId != null) Phase phase = Document.GetElement(phaseId) as Phase; //room number Parameter parameter = element.get_Parameter(BuiltInParameter.ROOM_NUMBER); string roomNumber = (parameter.HasValue) ? parameter.AsString() : String.Empty; //room occupancy Parameter parameter = element.get_Parameter(BuiltInParameter.ROOM_OCCUPANCY); string roomOccupancy = (parameter.HasValue) ? parameter.AsString() : String.Empty; //room location LocationPoint point = room.Location as LocationPoint //room name //Note : you can access also room.Name - but this property will compose the actual name with the number of the room Parameter parameter = element.get_Parameter(BuiltInParameter.ROOM_NAME); string roomName = (parameter.HasValue) ? parameter.AsString() : String.Empty; //room department Parameter parameter = element.get_Parameter(BuiltInParameter.ROOM_DEPARTMENT); string roomDepartment = (parameter.HasValue) ? parameter.AsString() : String.Empty; //door height Parameter parameter = element.get_Parameter(BuiltInParameter.DOOR_HEIGHT); double doorHeight = (parameter.HasValue) ? parameter.AsDouble() : 0; //door width Parameter parameter = element.get_Parameter(BuiltInParameter.DOOR_WIDTH); double doorWidth = (parameter.HasValue) ? parameter.AsDouble() : 0; //door mark Parameter parameter = element.get_Parameter(BuiltInParameter.DOOR_NUMBER); double doorMark = (parameter.HasValue) ? parameter.AsDouble() : 0; //window height Parameter parameter = element.get_Parameter(BuiltInParameter.WINDOW_HEIGHT); double windowHeight = (parameter.HasValue) ? parameter.AsDouble() : 0; //window width Parameter parameter = element.get_Parameter(BuiltInParameter.WINDOW_WIDTH); double windowWidth = (parameter.HasValue) ? parameter.AsDouble() : 0; //Same enumeration value as for door is used for windows : Parameter parameter = element.get_Parameter(BuiltInParameter.DOOR_NUMBER); double windowMark = (parameter.HasValue) ? parameter.AsDouble() : 0; //Family instance comment Parameter parameter = element.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS); string comment = (parameter.HasValue) ? parameter.AsString() : String.Empty;
Hi! Some resources say that get_Parameter method is obsolete from 2015 and recommend to use other methods to get parameters. For example get_Parameter is not listed as member of the Element class in the API documents.
But I wonder, what is the correct way to get built in parameters now? I cannot find any that get BuitInParameter as the argument
Hi,
I will post an article on this shortly
One method i found is:
https://digitteck.com/dotnet/revitapidotnet/revitapi-parameter-by-builtinparameter/