Revit API does not provide a straightforward method to detect whether a wall is linear or curved.
We can create help methods to do so by ourselves. Two effective means are listed as follows.
Means #1: Using the Location type
public static bool IsCurvedWall1(Element e)
{
if (!(e is Wall)) return false;
if (e.Location is LocationCurve && (e.Location as LocationCurve).Curve is Arc ) return true;
return false;
}
For curved walls, the LocationCurve will be of type Arc; for linear walls, something else.
Means #2: Using the CURVE_ELEM_ARC_RADIUS parameter
public static bool IsCurvedWall2(Element e)
{
if (!(e is Wall)) return false;
Parameter p = e.get_Parameter(BuiltInParameter.CURVE_ELEM_ARC_RADIUS);
if (p != null && p.AsDouble() > 0 && p.AsDouble() < double.MaxValue ) return true;
return false;
}
For curved walls, the parameter value will be greater than zero and less than infinitive.
Here is the test code:
…
Element pickedElement = cmdData..ActiveUIDocument.Selection.PickObject(ObjectType.Element, "Pick an element").Element;
MessageBox.Show(IsCurvedWall1(pickedElement).ToString());
MessageBox.Show(IsCurvedWall2(pickedElement).ToString());
…
Obviously, it would be more convenient and concise if the code were written as extension methods to the Wall class. It is not so hard. Please feel free to do so as an assignment if you like.
RevitAddinWizard coders will use the methods when necessary.
Recent Comments