2027 Method
Changes 0
M

Location.Rotate

Description:
Rotate the element within the project by a specified angle around a given axis.
Remarks:
The rotate method is used to rotate an element within the project. Other elements may also be rotated when this element is rotated because they are dependent upon the element being rotated. An unbounded line for the axis can be created by using the Application.Create object and its methods.
public bool Rotate(
	Line axis,
	double angle
)
  • axis
    An unbounded line that represents the axis of rotation.
  • Double
    angle
    The angle, in radians, by which the element is to be rotated around the specified axis.
Return Value Boolean If the element is rotate successfully then the method returns True, otherwise False.
bool LocationRotate(Autodesk.Revit.ApplicationServices.Application application, Autodesk.Revit.DB.Element element)
{
    bool rotated = false;
    // Rotate the element via its location curve.
    LocationCurve curve = element.Location as LocationCurve;
    if (null != curve)
    {
        Curve line = curve.Curve;
        XYZ aa = line.GetEndPoint(0);
        XYZ cc = new XYZ(aa.X, aa.Y, aa.Z + 10);
        Line axis = Line.CreateBound(aa, cc);
        rotated = curve.Rotate(axis, Math.PI / 2.0);
    }

    return rotated;
}