Hi All,
Finally, i got the solution. As suggested by Jeremy, I had tried with "Area" element bounding box co-ordinates and got the success.
Below is the approach i have used to calculate width/length of an "Area" element. Let me know, if anyone find this useful.
Approach :-1. Get the min & max point of "Area" element bounding box.
2. Then get respective end points (end points from bounding box's min point in both the directions).
3. Construct a Line by using Line.CreateBound().
4. Use length of the constructed line object.
Code :-
public static UV CheckFunctionalAreaDimensions(Element selectedElement, Document doc)
{
UV dimension = null;
if (selectedElement != null)
{
Type _type = selectedElement.GetType();
if (_type == typeof(Area))
{
Area selectedAreaObject = selectedElement as Area;
BoundingBoxXYZ box = selectedAreaObject.get_BoundingBox(doc.ActiveView);
XYZ targetX = new XYZ(box.Min.X,box.Max.Y,box.Min.Z);
XYZ targetY = new XYZ(box.Max.X,box.Min.Y,box.Min.Z);
double width = CalculateAreaWidthLength(doc, box.Min, targetX);
double length = CalculateAreaWidthLength(doc, box.Min, targetY);
dimension = new UV(length, width);
}
}
return dimension;
}
public static double CalculateAreaWidthLength(Document doc, XYZ startingPoint, XYZ endingPoint)
{
double length = 0;
Line objLine = Line.CreateBound(startingPoint, endingPoint);
length = objLine.Length;
return length ;
}