I want to get the length and width values of a room within Revit but it appears that Revit does not give access to these values like it does with room perimeter, area and volume.
I decided to start by finding the length value for a room through code as I can calculate the width using the length but I am getting results that do not seem correct, below is the relevant part of my code:
Room room = oneRoom as Room;
double area = room.Area;
double perimeter = room.Perimeter;
int roomArea = (int)area;
int roomPerimeter = (int)perimeter;
int length = (int)(((roomPerimeter / 2) - Math.Sqrt((roomPerimeter / 2) ^ 2 - 4 * roomArea)) / 2);
//int width = roomArea / length;
string valueMessage = "perimeter of room is " + length;
TaskDialog.Show("Message", valueMessage);
I am using an equation to work out the length given the area and the perimeter. The value i get back however is -21,474,836,648 which even if I treat the value as cm and ignore that it is a minus value, is insanely high and can't be correct.
For context on the room, it is a rectangle, the perimeter is 116.141732283465 and the area is 755.626511253023
Any help on fixing this issue is appreciated